Is this the correct way to use "hold on" in a for loop?

59 次查看(过去 30 天)
I am new to MATLAB and just trying to run a program for projection motion. I feel I am using the hold on and hold off in the correct way but I'm greeted with empty plot. Can someone please point out the mistake in the code?

回答(2 个)

Yongjian Feng
Yongjian Feng 2021-8-5
You only need to hold on for the first plot call, right?

Star Strider
Star Strider 2021-8-5
Is this the correct way to use "hold on" in a for loop?
That is not the way I would do it.
Try this instead:
figure
hold on
for t = 1:5
dx = ...
dy = ...
plot(dx, dy, 'g-')
end
hold off
grid
.
  2 个评论
PASUNURU  SAI VINEETH
I tried your way but it didn't result in the plot either. I was able to do it by eliminating for loop but can't find a way when I have to use it.
Star Strider
Star Strider 2021-8-5
I canot run images of code, only actual code, so I could not run what was posted.
If you are plotting points, do this instead, in the loop:
plot(x, y, 'p')
to plot the points as stars without connecting lines.
.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by