Hello everyone,
I need your help with accessing a field from a struct. I am not really familiar with how to use structs.
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
Stephen23 2020 年 9 月 25 日
編集済み: Stephen23 2020 年 9 月 25 日
Structure arrays have two independent features which need to be considered when accessing their data:
  • the size, which determines what indexing you can use.
  • the fields, which determines what field names you can use.
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
Ameer Hamza 2020 年 9 月 25 日
編集済み: Ameer Hamza 2020 年 9 月 25 日

0 投票

You need to use concatenation brackets [ ]
a=[structname.MeansArea]

2 件のコメント

N/A
N/A 2020 年 9 月 25 日
Thanks for the fast and correct answer.
Ameer Hamza
Ameer Hamza 2020 年 9 月 25 日
I am glad to be of help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

製品

リリース

R2019b

質問済み:

N/A
2020 年 9 月 25 日

編集済み:

2020 年 9 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by