For Loop to Cycle through Struct

10 ビュー (過去 30 日間)
Nat Person
Nat Person 2021 年 1 月 13 日
I have a 6x1 struct and want to create a for loop that will cycle through and pull out the name field of the 1x1 struct.
How can I do that? ** I am using R2012a **
I apologize for the strange format, the toolbar at the top of the body is missing and I'm still trying to fix it.
  2 件のコメント
Athrey Ranjith Krishnanunni
Athrey Ranjith Krishnanunni 2021 年 1 月 15 日
You probably don't need a for loop, you can use the function fieldnames(S) (look at its documentation for more info).
P. S. You can use Alt + Enter to switch between code and plain text modes.
AANJANEY KUMAR VERMA
AANJANEY KUMAR VERMA 2022 年 7 月 25 日
listNames = { YourStructArray.Name };
This will return a cell array of all the names present in the array of structs.
Hope this helps

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品


リリース

R2012a

Community Treasure Hunt

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

Start Hunting!

Translated by