v = nonzeros(A)
| Parameter | Description |
|---|---|
| A | numeric, logical, or character array, including sparse numeric and sparse logical matrices. |
| Parameter | Description |
|---|---|
| v | dense column vector containing the nonzero values of A. |
nonzeros returns the nonzero values of A in column-major order.
For sparse input, the output is a dense column vector containing only values that are actually nonzero. Stored zero values in a sparse matrix are skipped.
The output keeps the value class of A, including single, complex single, logical, and integer inputs.
A = sparse([1 0 2; 0 3 0]);
v = nonzeros(A)
S = sparse([1 2 1 2], [1 1 2 2], single([0 -0 complex(0, 0) complex(0, 2)]), 2, 2, 4);
v = nonzeros(S)
| Version | Description |
|---|---|
| 2.0.0 | initial version |