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.
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