Number of nonzero matrix elements
n = nnz(X)
n = nnz(X) returns the
number of nonzero elements in matrix
The density of a sparse matrix is
w = sparse(wilkinson(21));
is a tridiagonal matrix with
on each of three diagonals, so
nnz(w) = 60.
This function fully supports tall arrays. For more information, see Tall Arrays.