Mathematics Previous page   Next Page

The find Function and Sparse Matrices

For any matrix, full or sparse, the find function returns the indices and values of nonzero elements. Its syntax is

find returns the row indices of nonzero values in vector i, the column indices in vector j, and the nonzero values themselves in the vector s. The example below uses find to locate the indices and values of the nonzeros in a sparse matrix. The sparse function uses the find output, together with the size of the matrix, to recreate the matrix.


Previous page  Viewing Sparse Matrices Graphically Adjacency Matrices and Graphs Next page

© 1994-2005 The MathWorks, Inc.