next up previous contents
Next: SPEYE Sparse Identity Matrix Up: Sparse Matrix Support Previous: EIGS Sparse Matrix Eigendecomposition   Contents

Subsections

SPONES Sparse Ones Function

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 = 
  <int32>  - size: [3 5]
 
Columns 1 to 5
             1              0              3              0              5  
             0              0              2              3              0  
             1              0              0              0              1  
--> b = spones(a)
b = 
  <float>  - size: [3 5]
	Matrix is sparse with 7 nonzeros
--> full(b)
ans = 
  <float>  - size: [3 5]
 
Columns 1 to 3
    1.0000000          0.00000000         1.0000000       
    0.00000000         0.00000000         1.0000000       
    1.0000000          0.00000000         0.00000000      
 
Columns 4 to 5
    0.00000000         1.0000000       
    1.0000000          0.00000000      
    0.00000000         1.0000000



Samit K. Basu 2005-03-16