How to plot values over time?

28 ビュー (過去 30 日間)
zephyr21
zephyr21 2016 年 6 月 21 日
コメント済み: Walter Roberson 2016 年 6 月 22 日
I have an output that spits out 60 different values over the course of N=60 timesteps. How can I plot these values vs time? My current code is:
for n=1:N
plot(T(n),rate(4,10,n))
end
rate(4,10,n) indicates the value at i=4 and j=10 of that matrix

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 6 月 21 日
You could add a drawnow() or pause() after your plot() call.
You might also want to see animatedline() . It is also common to use waterfall plots with x being the time axis.
  2 件のコメント
zephyr21
zephyr21 2016 年 6 月 21 日
I keep getting a blank graph. rate(:,:,n) is an 11,14 matrix at timestep n. I specify rate(4,10,n) because there is only one number in that matrix, at (4,10)
Walter Roberson
Walter Roberson 2016 年 6 月 22 日
The default marker is empty for plot, and when you only plot one point at a time there will be no line to connect. You should specify a marker, like
plot(T(n), rate(4,10,n), '*')
However you should only do that if you want the position to be "animate". If you just want to draw all of them, then you should not use a loop and should instead use
plot(T(1:n), rate(4, 10, 1:N))

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by