looping over structure fields

조회 수: 15 (최근 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by