Why is my plot plotting blank?

20 次查看(过去 30 天)
Shuqing Qi
Shuqing Qi 2021-2-2
Why I keep getting blank for my graph? I figured out that if I change plot(i,P_t(i+1)) to plot(i,P_t(i+1),'.');hold on, it will work. But only I want is a smooth line printed.

回答(1 个)

Timo Dietz
Timo Dietz 2021-2-2
Each loop you are plotting one point, only. So you either have to "hold on" the figure to prevent erasing all data before the next point to plot (this would give you some kind of scatter plot) or you have to plot the array at the end of the function.
So to get a line the last row in the function should look like
plot([1:Year+1], P_t)
You got the point?
  3 个评论
Shuqing Qi
Shuqing Qi 2021-2-2
Thank you so much! I got it!
Timo Dietz
Timo Dietz 2021-2-3
Glad that I could help you. Please accept the answer to close the topic.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by