Mathematics |
Importing Sparse Matrices from Outside MATLAB
You can import sparse matrices from computations outside MATLAB. Use the spconvert
function in conjunction with the
load
command to import text files containing lists of indices and nonzero elements. For example, consider a three-column text file
T.dat
whose first column is a list of row indices, second column is a list of column indices, and third column is a list of nonzero values. These statements load T.dat
into MATLAB and convert it into a sparse matrix S
:
The save
and
load
commands can also process sparse matrices stored as binary data in MAT-files.
Creating Sparse Matrices | Viewing Sparse Matrices |
© 1994-2005 The MathWorks, Inc.