Get structure field names in recursive manner
NAMES = fieldnamesr(S) returns a cell array of strings containing the structure field names associated with s, the structure field names of any structures which are fields of s, any structures which are fields of fields of s, and so on.
NAMES = fieldnamesr(S,DEPTH) is an optional field which allows the depth of the search to be defined. Default is -1, which does not limit the search by depth. A depth of 1 will return only the field names of s (behaving like FIELDNAMES). A depth of 2 will return those field names, as well as the field names of any structure which is a field of s, and so on.
NAMES = fieldnamesr(...,'full') returns the names of fields which are structures, as well as the contents of those structures, as separate cells. This is unlike the default where a structure-tree is returned.
NAMES = fieldnamesr(...,'prefix') returns the names of the fields prefixed by the name of the input structure.
NAMES = fieldnamesr(...,'struct') returns only the names of fields which are structures.
Cite As
Adam (2024). Get structure field names in recursive manner (https://www.mathworks.com/matlabcentral/fileexchange/33262-get-structure-field-names-in-recursive-manner), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Acknowledgements
Inspired: json2xls, isempty_field - Easily check whether a deeply nested field is empty or non-existent
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |