Store each value generated in a for loop
4 ビュー (過去 30 日間)
古いコメントを表示
I have a bit of code which generates a value P and updates it every iteration. How can i store each of these values generated and then plot them on a graph?
0 件のコメント
回答 (1 件)
David Hill
2022 年 3 月 9 日
for k=1:100
p(k)=%your update for p
end
plot(p);
2 件のコメント
David Hill
2022 年 3 月 11 日
Use a cell array. Your sizes each iteration might be different based on the number of nonzeros.
P=cell(1000,1);
for n = 1:1000
P{n} = nonzeros(Q_new.*C);
end
参考
カテゴリ
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!