Make a point move straight up and down
6 views (last 30 days)
Show older comments
Hi,
I would like to know how to plot a point and just make it go up, down, and back to the starting point. I was thinking about making a list of y values but was not sure if there was a simpler way.
Thanks
0 Comments
Answers (2)
Sulaymon Eshkabilov
on 15 Aug 2020
Hi,
A simple motion or animation tool with plot tools is drawnow that can be employed in your task, e.g.:
2 Comments
Sulaymon Eshkabilov
on 15 Aug 2020
Hi,
If I've understood your question correctly, you'd like to get a up and down motion of a point x, y(i). Then here is one of the possible animated plots with drawnow:
for ii=1:numel(x) %loop
plot(x,y, '--', px, y(ii),'o', 'markerfacecolor', 'y'); %circle point
hold off
drawnow
end
See Also
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!