MATLAB Function Reference Previous page   Next Page
spones

Replace nonzero sparse matrix elements with ones

Syntax

Description

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

Examples

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

nnz, spalloc, spfun


Previous page  spline spparms Next page

© 1994-2005 The MathWorks, Inc.