Assign a Name for Each Iteration
1 回表示 (過去 30 日間)
古いコメントを表示
I'm trying to assign a name for each iteration in a for loop. Let's take the fundamental for loop:
for i = 1:3
x = i^2
end
And the the output is:
x = 1;
x = 4;
x = 9;
What I want to do is assign the x's as x(1),x(2), and x(3). So what I'm trying to achieve is to have a for loop output as:
x(1) = 1;
x(2) = 4;
x(3) = 9;
Thanks,
Amanda
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2013 年 5 月 9 日
編集済み: Azzi Abdelmalek
2013 年 5 月 9 日
for i = 1:3
x(i) = i^2
end
0 件のコメント
参考
カテゴリ
Help Center および 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!