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