Code covered by the BSD License  

Highlights from
Recursive version of isempty() for cells and structures

Be the first to rate this file! 1 Download (last 30 days) File Size: 2.05 KB File ID: #33030

Recursive version of isempty() for cells and structures

by Kevin Bartlett

 

26 Sep 2011

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

| Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File  
Everyone's Tags
cell, cell array, empty, field, isempty, structure
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.

Contact us