Returns a dense column vector containing the nonzero elements of the argument matrix. The syntax for its use is
y = nonzeros(x)
where x is the argument array. The argument matrix may
be sparse as well as dense.
Here is an example of using 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 13 nonzeros
--> nonzeros(A)
ans =
<double> - size: [13 1]
Columns 1 to 1
0.126986816293506
0.0975404049994095
0.157613081677548
0.141886338627215
0.0357116785741896
0.171186687811562
0.0318328463774207
0.0461713906311539
0.0971317812358475
0.0344460805029088
0.186872604554379
0.162611735194631
0.118997681558377