looping over structure fields

13 visualizaciones (últimos 30 días)
hi  hey
hi hey el 10 de Mayo de 2018
Comentada: hi hey el 10 de Mayo de 2018
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

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 10 de Mayo de 2018
Editada: Fangjun Jiang el 10 de Mayo de 2018
for k=1:2:numel(fn)
tmp = Structure.Aww.(fn{k})
tmp2= Structure.Aww.(fn{k+1})
end

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by