Accessing all lower elements of a structure
Ältere Kommentare anzeigen
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 Kommentar
Shane Smith
am 3 Okt. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Structures finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!