Flexible search and listing tool for field names in a subscripted structure array

Searches for field names in an optionally subscripted structure array and lists them

89 Downloads

Updated 20 Feb 2015

View License

Call options:
-------------
SearchStruct AStruct
SearchStruct('AStruct')
- Displays all fields in (optionally subscripted) structured array AStruct with their complete ("long") names.

SearchStruct AStruct SearchString
SearchStruct('AStruct','SearchString')
- Displays all fields in structured array AStruct of which the name contains SearchString (default = case-insensitive).

SearchStruct AStruct SearchString SearchOption
SearchStruct('AStruct', 'SearchString', 'SearchOption')
- The following options may be indicated by SearchOption:
default - Default (case-insensitive search, see above).
case - Case-sensitive search.
exact - Only those field names are listed which matches the SearchString exactly (case-insensitive search).
exactcase - The same as "exact", but with case-sensitive search.
begin - Only those field names are listed of which the beginning matches the SearchString (case-insensitive search).
begincase - The same as "begin", but with case-sensitive search.
end - Only those field names are listed of which the end matches the SearchString (case-insensitive search).
endcase - The same as "end", but with case-sensitive search.
If no option is given, "default" is assumed.

FoundFieldsList = SearchStruct('AStruct', ...)
- A list of the found field names is stored as a cellular string array into the output variable FoundFieldsList.

If no output variable is indicated, the names are printed as a list on the screen.

Example of function call:
------------------------
SearchStruct ExampleStruct afield

Result (example):
----------------
ExampleStruct.AField
ExampleStruct.AnotherField{2,3}.AField
ExampleStruct.AnotherField{2,3}.AField2

Cite As

Paul A.M. Bune (2023). Flexible search and listing tool for field names in a subscripted structure array (https://www.mathworks.com/matlabcentral/fileexchange/49775-flexible-search-and-listing-tool-for-field-names-in-a-subscripted-structure-array), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013b
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!
Version Published Release Notes
1.0.0.0