Section: Sparse Matrix Support
float
matrix with ones where the argument
matrix has nonzero values. The general syntax for it is
y = spones(x)
where x
is a matrix (it may be full or sparse). The output
matrix y
is the same size as x
, has type float
, and contains
ones in the nonzero positions of x
.
spones
function
--> a = [1,0,3,0,5;0,0,2,3,0;1,0,0,0,1] a = 1 0 3 0 5 0 0 2 3 0 1 0 0 0 1 --> b = spones(a) b = Matrix is sparse with 7 nonzeros --> full(b) ans = 1 0 1 0 1 0 0 1 1 0 1 0 0 0 1 --> quit