Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Handle Sparse Arrays

The MATLAB® API provides a set of functions that allow you to create and manipulate sparse arrays from within your MEX files. These API routines access and manipulate ir and jc, two of the parameters associated with sparse arrays. For more information on how MATLAB stores sparse arrays, see The MATLAB Array.

The example fulltosparse.c shows how to populate a sparse matrix.

Build the example.

mex fulltosparse.c

Create a full, 5-by-5 identity matrix.

full = eye(5)
full =
     1     0     0     0     0
     0     1     0     0     0
     0     0     1     0     0
     0     0     0     1     0
     0     0     0     0     1

Call fulltosparse to produce the corresponding sparse matrix.

spar = fulltosparse(full)
spar =
   (1,1)        1
   (2,2)        1
   (3,3)        1
   (4,4)        1
   (5,5)        1

Related Topics

Was this topic helpful?