StructSearch(input_​struct,search_term)

searches and returns details and child struct with matching parameters.
29 Downloads
Updated 27 Apr 2018

View License

Input:
1.struct (Nested)
2. search string(Case insensitive) to find a member.
Output:
1.Results: [nx4 string] -> [matching_member full_path_of_that_member Class_of_member Description_of_member ]
2.Child_struct= A struct formed with the matching members while preserving the hierarchy.
Application: Useful for nested struct with large number of members. I used it is for MRI data processing.
Eg:
%Example nested struct
P_struct=struct('array_small',[5 6],'array_large',ones(2,3,5),'string', 'Example');
P_struct.N1_strct=struct('string', 'Nested struct 1');
P_struct.N1_strct.N2_struct=struct('string', 'In Nested struct 2');
%Usage
[details, child]=StructSearch(P_struct,'strin');
%output
details =
3×4 string array
"string" "P_struct.string" "char" "Example"
"string" "P_struct.N1_strct.st…" "char" "Nested struct 1"
"string" "P_struct.N1_strct.N2…" "char" "In Nested struct 2"

child =
struct with fields:
string: 'Example'
N1_strct: [1×1 struct]

Cite As

Praveen Iyyappan Valsala (2024). StructSearch(input_struct,search_term) (https://www.mathworks.com/matlabcentral/fileexchange/67096-structsearch-input_struct-search_term), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017b
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.2.0.0

Forgot to upload updated file:P

1.1.0.0

1. Input arguments error handling

1.0.0.0