Borrar filtros
Borrar filtros

how to change the increment in for loop?

3 visualizaciones (últimos 30 días)
Sarah A
Sarah A el 1 de Ag. de 2018
Editada: madhan ravi el 2 de Ag. de 2018
Hello,
I have this line of code in C++ and I need to know its equivalent in Matlab:
for (i =0 , i<100 , i=i+4)
?

Respuesta aceptada

madhan ravi
madhan ravi el 1 de Ag. de 2018
Editada: madhan ravi el 1 de Ag. de 2018
hi, this is how you do it:
for i = 0:4:(100-1)
i
end
EXPLANATION: O IS THE STARTING POINT AND 4 IS THE INCREMENT , IT GOES ALL THE WAY UP UNTIL THE LIMIT (100-1)<=>99
  2 comentarios
Sarah A
Sarah A el 1 de Ag. de 2018
Thank you :)
madhan ravi
madhan ravi el 2 de Ag. de 2018
Editada: madhan ravi el 2 de Ag. de 2018
you're welcome

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