Skip to Main Content Skip to Search
Product Documentation

nzmax - Amount of storage allocated for nonzero matrix elements

Syntax

n = nzmax(S)

Description

n = nzmax(S) returns the amount of storage allocated for nonzero elements.

If S is a sparse matrix...

nzmax(S) is the number of storage locations allocated for the nonzero elements in S.

If S is a full matrix...

nzmax(S) = prod(size(S)).

Often, nnz(S) and nzmax(S) are the same. But if S is created by an operation which produces fill-in matrix elements, such as sparse matrix multiplication or sparse LU factorization, more storage may be allocated than is actually required, and nzmax(S) reflects this. Alternatively, sparse(i,j,s,m,n,nzmax) or its simpler form, spalloc(m,n,nzmax), can set nzmax in anticipation of later fill-in.

See Also

find | isa | nnz | nonzeros | size | whos

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS