Section: Array Generation and Manipulations
y = nonzeros(x)
where x
is the argument array. The argument matrix may
be sparse as well as dense.
nonzeros
on a sparse matrix.
--> a = rand(8); a(a>0.2) = 0; --> A = sparse(a) A = Matrix is sparse with 19 nonzeros --> nonzeros(A) ans = 0.1767 0.0337 0.1943 0.0846 0.0200 0.1884 0.0519 0.0745 0.0538 0.0838 0.0560 0.1657 0.0433 0.1788 0.1374 0.1702 0.0513 0.1767 0.0528 --> quit