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 14 nonzeros --> nonzeros(A) ans = <double> - size: [14 1] Columns 1 to 1 0.059999257236061587 0.079567788295536346 0.081845950340716178 0.094757664191197577 0.105960788044496268 0.164727193353919721 0.047921992919421119 0.148867177299415232 0.107037725053110711 0.039317648439958330 0.048575622015640030 0.028569429009401293 0.160675292358725685 0.106916122215555687