File Exchange

image thumbnail


version 2.0 (4.88 KB) by

HASFIELD finds the first struct member called fieldname, use HASFIELDRX to find first regex match

1 Download


HASFIELD is an improvement in ISFIELD where the purpose is to search structs within structs for a field name. To this end it also provides the level that the field was FIRST found on, using a breadth first search. By default it will search exhaustively, but can be limited by the second parameter to N-levels, treating the parent struct as the root of a tree.
d.c.a = 1;
d.c.b = 2;
d.c.c = 3;
d.c.d.a = 1;
d.c.d.b.waldo = 'where?'
d.c.d.walbo = 'wear?'
[x,L] = hasfield(d,'waldo')

x =



L =


Comments and Ratings (0)



added regex matching variant and fixed a bug


added unit test outputs for more descriptive overview

MATLAB Release
MATLAB 7.2 (R2006a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video