How to plot a graph with a set of updated values from the for loop?
1 回表示 (過去 30 日間)
古いコメントを表示
I have to plot a graph with number of iterations on the x axis and the updated values for each iterations(ie, set of values) in y axis.How to plot this?
0 件のコメント
回答 (1 件)
Voss
2022 年 2 月 17 日
It might be something like this:
ii = 1;
x = 1;
y = 1;
while ii < 10
x(ii+1) = x(ii)+1;
y(ii+1) = y(ii)*2;
ii = ii+1;
end
plot(1:ii,x,'-x');
hold on
plot(1:ii,y,'-o');
legend('x','y');
xlabel('Iteration No.');
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!