15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6 Sparse Matrices<br />

Importing Sparse Matrices from Outside <strong>MATLAB</strong><br />

You can import sparse matrices from computations outside <strong>MATLAB</strong>. Use the<br />

spconvert function in conjunction with the load command to import text files<br />

containing lists <strong>of</strong> indices and nonzero elements. For example, consider a<br />

three-column text file T.dat whose first column is a list <strong>of</strong> row indices, second<br />

column is a list <strong>of</strong> column indices, and third column is a list <strong>of</strong> nonzero values.<br />

These statements load T.dat into <strong>MATLAB</strong> and convert it into a sparse<br />

matrix S:<br />

load T.dat<br />

S = spconvert(T)<br />

The save and load commands can also process sparse matrices stored as binary<br />

data in MAT-files.<br />

6-12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!