External Interfaces Previous page   Next Page

Handling Sparse Matrices

The MATLAB API provides a set of functions that allow you to create and manipulate sparse matrices from within your MEX-files. There are special parameters associated with sparse matrices, namely ir, jc, and nzmax. For information on how to use these parameters and how MATLAB stores sparse matrices in general, refer to the section on The MATLAB Array.

This example illustrates how to populate a sparse matrix.

This is the subroutine that fulltosparse calls to fill the mxArray with the sparse data.

At the MATLAB prompt, entering

creates a full, 5-by-5 identity matrix. Using fulltosparse on the full matrix produces the corresponding sparse matrix.


Previous page  Dynamically Allocating Memory Calling Functions from Fortran MEX-Files Next page

© 1994-2005 The MathWorks, Inc.