MATLAB Functions | Help Desk |
nnz
Number of nonzero matrix elements
n=
nnz(X)
n = nnz(X)
returns the number of nonzero elements in matrix X
.
The density of a sparse matrix is nnz(X)/prod(size(X))
.
The matrix
w = sparse(wilkinson(21));
is a tridiagonal matrix with 20
nonzeros on each of three diagonals, so nnz(w) = 60
.
find
Find indices and values of nonzero elements
nonzeros
Nonzero matrix elements
nzmax
Amount of storage allocated for nonzero matrix
elements
size
Array dimensions
whos
List directory of variables in memory
isa
Detect an object of a given class