Back to Sparse Matrices
nnz
Number of nonzero matrix elements
Syntax
n = nnz(S)
Description
Returns the number of nonzero elements in sparse matrix S, or the number of nonzero elements in a full matrix.
Parameters
| Name | Description |
|---|---|
| S | Sparse or full matrix |
Returns
Number of nonzeros