nonzeros
Column vector of non-zero elements.
Syntax
Section titled “Syntax”v = nonzeros(A)Description
Section titled “Description”Returns a column vector of the non-zero elements of A, in column-major order. Works on both sparse and full matrices. Length of the result equals nnz(A).
Examples
Section titled “Examples”S = sparse([1 0 0; 0 2 0; 3 0 0]);nonzeros(S) % [1; 3; 2] (column-major order)