Manipulating outputted answers from a loop

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

 채택된 답변

Paulo Silva
Paulo Silva 2011년 3월 14일

1 개 추천

N=10;
x=zeros(N,1);
for i = 1:N
x(i) = 2*i;
end

댓글 수: 2

Dominic Lawson
Dominic Lawson 2011년 3월 14일
thanks very much
Jan
Jan 2011년 3월 14일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by