how we write condition in for loop?

suppose in c language we have a condition like k=0;k<j;k++
how we write this code in matlab?

 Respuesta aceptada

Más respuestas (2)

Pruthvi G
Pruthvi G el 3 de Abr. de 2019
Editada: Pruthvi G el 3 de Abr. de 2019
Increment of 1
for k = 1:1:j % Increment of 1
% do operations
end
Increment of 2
for k = 1:2:j % Increment of 2
% do operations
end
Decrement from j to 1 in step of 1
for k = j:-1:1 % Decrement of -1
% do operations
end
Please Accept answer if you understood, else ping me for advanced help
Sanjoy Dey
Sanjoy Dey el 3 de Abr. de 2019
Editada: Sanjoy Dey el 3 de Abr. de 2019

0 votos

i know syntax of for loop--- for index=initial value : step size: final value
but i want to know the condition k<j,how i write this condition?

Categorías

Más información sobre MATLAB Coder en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 3 de Abr. de 2019

Editada:

el 3 de Abr. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by