issparse

Tests whether an array uses sparse storage.

Category: Language Fundamentals > Data Types

Syntax

tf = issparse(A)

Returns true if A is a sparse matrix.

Description

A sparse matrix stores only its nonzero entries. It is created by sparse or by functions such as speye, and many operations keep the result sparse. A full matrix that happens to contain mostly zeros is still full, so issparse is false for it.

Input arguments

A
Any value.

Output arguments

tf
Logical scalar.

Example

Sparse and full storage

issparse(sparse([1 0 0 2]))
issparse([1 0 0 2])
issparse(full(sparse([1 0 0 2])))
Output
ans = logical
   1
ans = logical
   0
ans = logical
   0

See also

sparse full nnz speye