Store all iteration loop outputs in a matrix
11 ビュー (過去 30 日間)
古いコメントを表示
clc;
a = 5;
b = 20;
for i = 1:10
j = (i + 25);
k = (j*b);
m =[i j k];
end
********************************
output:
m =
10 35 700
******************************************************************
Hi,
I am writing a program as mentioned above to store all iteration loop outputs in a matrix.
However, the output just displays the last iteration.
Could you please let me know the right code which is able to display all the iterations from 1 to 10.
Thank you very much
0 件のコメント
採用された回答
Mischa Kim
2014 年 7 月 8 日
編集済み: Mischa Kim
2014 年 7 月 8 日
UTS, use instead
m(i,:) = [i j k];
The output is an array m with 10 rows, 3 columns.
9 件のコメント
Ashish Kundaliya
2019 年 4 月 5 日
Hey @durga aryal, you might be doing a mistake like if you haven't applied for loop then it will show exactly what you are asking for?!
その他の回答 (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!