Hopefully I'll explain clearly as I haven't worked with structures much. I have been given a large 1×1 structure of arrays with numerous fields. I want to search one field to match a specific string. I then want to extract from the structure all fields for those cases where the string matched. I would prefer to do this with out loops. For an array of structures, I've been able to use logical indexing to access and extract data using "index2 = cellfun(@(x) any(strcmp(x, test)), {diab2.preg})" and then just index into the structure, but this doesn't work for a structure of arrays.
MATLAB: How to search a field in a structure and extract all fields that match
indexingstructure
Related Question
- How to print the structure, with several fields, as a title in MATLAB
- Removing structure field if
- How to get an index like with ismember, but with values representing the number of occurances
- Convert a 2×1 structure to 1×1 structure
- Reference to non existent field
- Trouble formating strings with fprintf.
- Create an array of single struct
Best Answer