For Loop Increment Value

57 visualizaciones (últimos 30 días)
HARSHVARDHAN SARAVANAKUMAR
HARSHVARDHAN SARAVANAKUMAR el 11 de Feb. de 2017
Comentada: HARSHVARDHAN SARAVANAKUMAR el 11 de Feb. de 2017
I am beginner in MATLAB. I want to write a for loop where the increment value should increase by 2.
For eg:
for i = 1:9
something
end
The value of i should be 1, 3, 5, 7, 9. Kindly help.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 11 de Feb. de 2017
Just do
for k=1:2:9
% do something
end
where we have defined the step size to be two.
  1 comentario
HARSHVARDHAN SARAVANAKUMAR
HARSHVARDHAN SARAVANAKUMAR el 11 de Feb. de 2017
Thank you. I feel silly. This was easy.

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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by