Manipulating outputted answers from a loop

7 visualizaciones (últimos 30 días)
Dominic Lawson
Dominic Lawson el 14 de Mzo. de 2011
Hello!
After looking for a solution to this problem for some time I am stuck.
When carrying out any loop for example
for i = 1:10
x = 2*i
end
How would one store all the values say in an array or a string so you could manipulate the answers of the loop further?
Thank you very much in advance

Respuesta aceptada

Paulo Silva
Paulo Silva el 14 de Mzo. de 2011
N=10;
x=zeros(N,1);
for i = 1:N
x(i) = 2*i;
end
  2 comentarios
Dominic Lawson
Dominic Lawson el 14 de Mzo. de 2011
thanks very much
Jan
Jan el 14 de Mzo. de 2011
Of course the example would be solved more efficiently by "x = 2:2:2*N", but Paulo's answer is useful more more complicated problems also.

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by