How to Keep Nested For Loop Indexes From Equaling Each Other

 Respuesta aceptada

Jason Nicholson
Jason Nicholson el 5 de Mayo de 2020
Editada: Jason Nicholson el 5 de Mayo de 2020
Use the continue keyword.
for i=1:50
for j=1:50
if j==i
continue; % breaks the inner for loop at the current iteration
else
% Do stuff here
fprintf('i=%d, j=%d\n',i,j);
end
end
end
If this response answers your question, please click "accept this answer."

Más respuestas (2)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 5 de Mayo de 2020

Comentada:

el 5 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by