File Exchange

image thumbnail

StructFind

version 1.0.0.0 (1.76 KB) by Alexander Mering
Find all fields within a struct (array) where the search pattern is found

2 Downloads

Updated 10 Feb 2012

View License

Function to search for entries within a structure. This is done recursively, running through all elements of array-structures.

Input:

search_struct: structure to be searched, could also be array of struct

search_object: string, integer, cell, array or other thing to be searched for

[optional]

structure_name: name of the structure to be searched. Used for full output of the structure content

Output:

FoundFields: Cell array of fields where the search object is found.

Cite As

Alexander Mering (2020). StructFind (https://www.mathworks.com/matlabcentral/fileexchange/35022-structfind), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Hello Brain, thanks for the feedback.

The problem is, that using regexpi would limit the search to purely string structures. So a plain replacement would be inadequat.

Nevertheless, this might be an option for further extension using search type discrimination or so.

Alexander

Brian

This was extremely helpful.

I modified the comparison from isequal to regexpi so I can find names with part of the string in. If you update this file, maybe add that as an option?

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: structfind