Accessing all lower elements of a structure
이전 댓글 표시
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!