Effacer les filtres
Effacer les filtres

Running two counter in one for statement

6 vues (au cours des 30 derniers jours)
Rich Cavanaugh
Rich Cavanaugh le 12 Avr 2018
Commenté : Rich Cavanaugh le 12 Avr 2018
Hello, I am trying to wright a for loop that has two counters that run counter to each other.
here is one of my attempts limiting the size of .rows and .cols to 3 in reality those values will be much larger
for (i = 1:3)
for(j = 3:-1:1)
handles.checkerDR{i}=...
handles.([handles.rows{i} handles.cols{j}]).String;
end
end
what I would like is checkerDR to be a cell array of
checkerDR{1}=handles.([handles.rows{1} handles.cols{3}).String;
checkerDR{2}=handles.([handles.rows{2} handles.cols{2}).String;
checkerDR{3}=handles.([handles.rows{3} handles.cols{1}).String;
so on and so forth does anyone have any ideas? i have been trying different iterations for a while and im not sure how to get this to work Thanks in advance

Réponse acceptée

Geoff Hayes
Geoff Hayes le 12 Avr 2018
Rich - try using just one for loop
maxIter = 3;
for k=1:maxIter
handles.checkerDR{k}=...
handles.([handles.rows{k} handles.cols{maxIter - k + 1}]).String;
end
  1 commentaire
Rich Cavanaugh
Rich Cavanaugh le 12 Avr 2018
that works perfectly. Thanks a million

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by