awmiller/hasfield_m​atlab

HASFIELD finds the first struct member called fieldname, use HASFIELDRX to find first regex match
176 Downloads
Updated 20 May 2017

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.
ex.
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 =

logical

1

L =

4

Cite As

Andrew Miller (2024). awmiller/hasfield_matlab (https://github.com/awmiller/hasfield_matlab), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Structures in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes
2.0.0.0

added regex matching variant and fixed a bug

1.0.0.0

added unit test outputs for more descriptive overview

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.