convert for loop to while

Can someone help me convert this for loop to a while loop?
v=0;
for n=1:length(i);
v=v+i(n);
end

Respuestas (1)

Adam
Adam el 9 de Nov. de 2016

0 votos

v = 0;
n = 1;
while n <= length( i )
v = v + i( n );
n = n + 1;
end
Quite why you would want to do this I don't know but anyway...

Categorías

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

Etiquetas

Preguntada:

el 9 de Nov. de 2016

Respondida:

el 9 de Nov. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by