looping over structure fields

4 vues (au cours des 30 derniers jours)
hi  hey
hi hey le 10 Mai 2018
Commenté : hi hey le 10 Mai 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

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 10 Mai 2018
Modifié(e) : Fangjun Jiang le 10 Mai 2018
for k=1:2:numel(fn)
tmp = Structure.Aww.(fn{k})
tmp2= Structure.Aww.(fn{k+1})
end
  1 commentaire
hi  hey
hi hey le 10 Mai 2018
thanks a lot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by