Skip to content

issparse

Test whether the input is a sparse matrix.

tf = issparse(S)

Returns logical true when S is stored in sparse format, false otherwise. Useful for branching on representation when a function should specialize differently for sparse vs. full inputs.

issparse(speye(5)) % 1
issparse(eye(5)) % 0
  • sparse — Create a sparse matrix.
  • full — Convert a sparse matrix to full storage.