Recursive version of isempty() for cells and structures

Returns true for cell arrays/structures that are not empty, but have only empty cells/fields.

You are now following this Submission

Matlab's isempty() returns false for a structured variable that contains one or more fields. In some circumstances, however, a structured variable may have been initialised with empty fields to be populated later; in this case, we might want to consider the structure to be empty if the fields themselves are empty.

isemptyr() tests for this condition by recursively checking the fields of a structured variable, returning true if only empty fields are found.

Similarly, for cell arrays, Matlab's isempty() returns false if the array contains one or more cells, even if they are empty. isemptyr(), in contrast, searches the cell array recursively, returning true if only empty cells are found.

isemptyr() works just like Matlab's isempty() for normal arrays and strings.

Cite As

Kevin Bartlett (2026). Recursive version of isempty() for cells and structures (https://au.mathworks.com/matlabcentral/fileexchange/33030-recursive-version-of-isempty-for-cells-and-structures), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0