looping over structure fields

3 ビュー (過去 30 日間)
hi  hey
hi hey 2018 年 5 月 10 日
コメント済み: hi hey 2018 年 5 月 10 日
Structure=struct('Aww',struct('y',[],'yes',[],'x',[],'no',[])
fn=fieldnames(Structure.Aww)
for k=1:numel(fn)
tmp = Structure.Aww(fn{k})
tmp1= Structure.Aww(fn{k+1})
end
I'm trying to get tmp to only loop over y and x and tmp1 to only loop over yes and no. I got tmp1 to work but I need a solution for tmp

採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 5 月 10 日
編集済み: Fangjun Jiang 2018 年 5 月 10 日
for k=1:2:numel(fn)
tmp = Structure.Aww.(fn{k})
tmp2= Structure.Aww.(fn{k+1})
end
  1 件のコメント
hi  hey
hi hey 2018 年 5 月 10 日
thanks a lot

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by