Contents Previous Next Subchapters

Obtaining the Nonzero Elements of a Matrix
Syntax nonzeros(x)
See Also find , nnz

Description
Returns a column vector with the same type as x containing the elements of x that are not equal to zero. The order of the elements in the return value is the same as their column major ordering in the matrix x

Example
If you enter
     x = [ 1 , 0 , 2 , 0 , 3 ];
     nonzeros(x)
O-Matrix will respond
     {
     1
     2
     3
     }