This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Determine whether array is empty


TF = isempty(A)


TF = isempty(A) returns logical 1 (true) if A is an empty array and logical 0 (false) otherwise. An empty array has at least one dimension of size zero, for example, 0-by-0 or 0-by-5.


collapse all

Determine if a multidimensional array is empty or not.

A = rand(2,2,2);
ans = logical

A(:,:,:) = [];
ans = logical


  • To determine whether a string array has empty strings (string elements with zero characters), use the == operator. For example, if str is a string containing zero characters, then str == "" returns logical 1 (true). For more information on testing empty strings, see Test for Empty Strings and Missing Values. For information on string comparison, see Compare Text.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

Introduced before R2006a