Method on @sym: nnz (A)

Number of non-zero elements in the symbolic array.

Example:

A = sym([1 0 0; 0 1 0]);
nnz(A)
  ⇒ ans =  2

See also: @sym/numel.

Package: symbolic