Skip to content

isempty

Test whether the input has zero elements.

tf = isempty(A)

Returns logical true when A contains no elements (an empty matrix [], an empty string '', or any other zero-size value), and false otherwise.

In the default script mode, isempty is applied elementwise for non-scalar inputs — useful for checking emptiness of every cell in a cell array. In Excel-compatible mode (cell formulas), the result is always a single scalar.

isempty([]) % 1
isempty('') % 1
isempty([1 2 3]) % 0
isempty(zeros(0,5)) % 1
  • isscalar — Test whether the input is a 1×1 scalar.
  • isvector — Test whether the input is a vector (one row or one column).
  • numel — Total number of elements.
  • size — Sizes along all dimensions, or along one specific dimension.