Accessing all lower elements of a structure
Show older comments
I'm attempting to set up my data in a format that makes it easy to access and understand, so I have utilized structures. Each 'variable' is a structure that has has a field for name, value, units, and a description. Then the sets of variables are organized into groups that make sense for my application. However, I am having issues accessing all elements of those groups. I would like to display the data in a table inside of a GUI, so I wanted to access the underlying elements by what would be in each column (name, value, unit, description), here is a simple example:
>> test.group1.foo.name = 'My name is foo';
>> test.group1.bar.name = 'My name is bar';
>> test.group1(:).name
Reference to non-existent field 'name'.
So there will be several groups, and they will have many variables (foo & bar in the example) but each variable will have a name that I'd like to access without a for-loop. In cells I was able to make use of the {:} operator to access each element of the cell individually, so I expected similar functionality for a structure.
Any help would be appreciated.
1 Comment
Shane Smith
on 3 Oct 2018
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!