SPONES Sparse Ones Function

Section: Sparse Matrix Support

Usage

Returns a sparse 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.

Examples

Here are some examples of the 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 = 
 1 1 1
 1 2 1
 1 3 1
 1 4 1
 1 5 1
--> full(b)

ans = 
 1 1 1 1 1 
 0 0 0 0 0 
 0 0 0 0 0