skip a number after every two number in for loop

2 visualizaciones (últimos 30 días)
yogi patel
yogi patel el 21 de En. de 2019
Comentada: yogi patel el 21 de En. de 2019
Hello,
I want to execute a for loop from value 1 to 10.
but within this range I want to skip number 3, 6 and 9. could you please help with the logic of skipping specific number at regular.

Respuesta aceptada

madhan ravi
madhan ravi el 21 de En. de 2019
Editada: madhan ravi el 21 de En. de 2019
L=1:10;
for k = L(~ismember(L,3:3:L(end)))
k
end
  4 comentarios
madhan ravi
madhan ravi el 21 de En. de 2019
Thank you John D‘Errico I was about to post this as another possible solution.
yogi patel
yogi patel el 21 de En. de 2019
Thank you John for brief answer. Always good to know new ideas regarding simple tasks. :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by