Back to Sparse Matrices
spones
Replace nonzero sparse matrix elements with ones
Syntax
R = spones(S)
Description
Returns a matrix with the same sparsity pattern as S but with all nonzero values replaced by 1.
Parameters
| Name | Description |
|---|---|
| S | Sparse matrix |
Returns
Sparse matrix with ones at nonzero positions
Examples
Try It
>> full(spones(sparse([1 0; 0 5])))