Home > Back-end >  MATLAB ball animation issues
MATLAB ball animation issues

Time:11-12

Such as topic, how to use MATLAB to do a little ball animation, require a known function image (such as y=sinx) then have a ball along the image from the beginning to the end finally returned or repetitive motion

CodePudding user response:

X=linspace (0,10,1000);
Y=sin (x);
The plot (x, y) % sine curve first
Hold on
H=the plot (x (1), y (1), 'o', 'MarkerFaceColor', 'red'). % draw point
Hold off
The axis manual
J=1;
While j> 0
For k=1: length (x)
h.XData=https://bbs.csdn.net/topics/x (k); % with handle change point data, is handle animation
h.YData=https://bbs.csdn.net/topics/y (k);
Drawnow
End
J=1
end
  • Related