Skip to content

nzmax

Storage allocated for non-zero elements.

n = nzmax(X)

Returns the amount of storage allocated for non-zero entries in X — for sparse matrices, this is >= nnz(X). Useful for diagnosing whether further insertions will trigger a reallocation.

S = spalloc(100, 100, 500);
nzmax(S) % 500
nnz(S) % 0 (allocated but unused)
  • nnz — Number of non-zero elements.
  • spalloc — Allocate space for an m × n sparse matrix.
  • sparse — Create a sparse matrix.