next up previous contents
Next: ISNAN Test for Not-a-Numbers Up: Inspection Functions Previous: EXIST Test for Existence   Contents

Subsections

ISSPARSE Test for Sparse Matrix

Usage

Test a matrix to see if it is sparse or not. The general format for its use is

   y = issparse(x)

This function returns true if x is encoded as a sparse matrix, and false otherwise.

Example

Here is an example of using issparse:

--> a = [1,0,0,5;0,3,2,0]
a = 
  <int32>  - size: [2 4]
 
Columns 1 to 4
             1              0              0              5  
             0              3              2              0  
--> issparse(a)
ans = 
  <logical>  - size: [1 1]
 0  
--> A = sparse(a)
A = 
  <int32>  - size: [2 4]
	Matrix is sparse with 4 nonzeros
--> issparse(A)
ans = 
  <logical>  - size: [1 1]
 1



Samit K. Basu 2005-03-16