This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Replace nonzero sparse matrix elements with ones


R = spones(S)


R = spones(S) generates a matrix R with the same sparsity structure as S, but with 1's in the nonzero positions.


c = sum(spones(S)) is the number of nonzeros in each column.

r = sum(spones(S'))' is the number of nonzeros in each row.

sum(c) and sum(r) are equal, and are equal to nnz(S).

See Also

| |

Introduced before R2006a

Was this topic helpful?