15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Viewing Sparse Matrices<br />

Note that initially nnz has the same value as nzmax by default. That is, the<br />

number <strong>of</strong> nonzero elements is equivalent to the number <strong>of</strong> storage locations<br />

allocated for nonzeros. However, <strong>MATLAB</strong> does not dynamically release<br />

memory if you zero out additional array elements. Changing the value <strong>of</strong> some<br />

matrix elements to zero changes the value <strong>of</strong> nnz, but not that <strong>of</strong> nzmax.<br />

However, you can add as many nonzero elements to the matrix as desired. You<br />

are not constrained by the original value <strong>of</strong> nzmax.<br />

Viewing Sparse Matrices Graphically<br />

It is <strong>of</strong>ten useful to use a graphical format to view the distribution <strong>of</strong> the<br />

nonzero elements within a sparse matrix. The <strong>MATLAB</strong> spy function produces<br />

a template view <strong>of</strong> the sparsity structure, where each point on the graph<br />

represents the location <strong>of</strong> a nonzero array element.<br />

For example,<br />

spy(west0479)<br />

0<br />

50<br />

100<br />

150<br />

200<br />

250<br />

300<br />

350<br />

400<br />

450<br />

0 100 200 300 400<br />

nz = 1887<br />

6-15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!