# nzmax

## Purpose

Amount of storage allocated for nonzeros in matrix.

## Synopsis

    n = nzmax(S)

## Description

`n = nzmax(S)`, where S is a sparse matrix, is the number of storage locations allocated for the nonzero elements in `S`. For a full matrix, `nzmax(A) = prod(size(A))`.

Often, `nnz(S)` and `nzmax(S)` are the same. But if `S` has been 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, issparse, nnz, nonzeros, size, whos

(c) Copyright 1994 by The MathWorks, Inc.