Filter löschen
Filter löschen

Running two counter in one for statement

6 Ansichten (letzte 30 Tage)
Rich Cavanaugh
Rich Cavanaugh am 12 Apr. 2018
Kommentiert: Rich Cavanaugh am 12 Apr. 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

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 12 Apr. 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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by