looping over structure fields

14 次查看(过去 30 天)
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