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 = <double> - size: [8 8] Matrix is sparse with 8 nonzeros --> nonzeros(A) ans = <double> - size: [8 1] Columns 1 to 1 0.098953370131552809 0.066184717220581502 0.021949046494394442 0.113011009385646233 0.144412295716459083 0.107450039193461300 0.008047519987897545 0.076519530544516101