- the size, which determines what indexing you can use.
- the fields, which determines what field names you can use.
Access Field from Struct
118 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
I need your help with accessing a field from a struct. I am not really familiar with how to use structs.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/366199/image.png)
I got this struct (not mine, therefore I don't really know how to properly work with it) and just want to plot the values that are in the first column.
There is probably a really easy way how to do it. I tried to access the data with something like a=structname.MeansArea, but this gives me only the very first entry of the column. I apprechiate all help.
1 件のコメント
Stephen23
2020 年 9 月 25 日
編集済み: Stephen23
2020 年 9 月 25 日
Structure arrays have two independent features which need to be considered when accessing their data:
For non-scalar structures you will likely find comma-separated lists to be very useful:
It is also possible to access the fieldnames dynamically:
採用された回答
Ameer Hamza
2020 年 9 月 25 日
編集済み: Ameer Hamza
2020 年 9 月 25 日
You need to use concatenation brackets [ ]
a=[structname.MeansArea]
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!