nz = nnz(X)
nz = nnz(X) is the number of nonzeros in matrix X.
The density of a sparse matrix, which is printed by the whos command, is nnz(X)/prod(size(X)).
is a tridiagonal matrix with 20 nonzeros on each of three diagonals, sow=sparse(wilkinson(21));
nnz(w) = 60.
find,issparse,nonzeros,nzmax,size,whos
(c) Copyright 1994 by The MathWorks, Inc.