Borrar filtros
Borrar filtros

Running two counter in one for statement

6 visualizaciones (últimos 30 días)
Rich Cavanaugh
Rich Cavanaugh el 12 de Abr. de 2018
Comentada: Rich Cavanaugh el 12 de Abr. de 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

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 12 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre MATLAB 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