Using the C Math Library    

Evaluating Arrays for Sparse Storage

To see if a MATLAB array is a good candidate for sparse format storage, determine the number of nonzero elements in an array, using the mlfNnz() routine. The following code fragment creates the same 12-by-12 identity matrix, shown in the example in Converting an Existing Matrix into Sparse Format, and then prints out the number of nonzero elements in the matrix.

This code outputs the number of nonzero elements in the 12-by-12 identity matrix: 12.


 Converting a Sparse Matrix to Full Matrix Format Character Arrays