MATLAB graphics drawing-the drawing of Li Saru's graphics and the animation of the generated trajectory

t = [0:0.02:10];
x = cos(t);
y = cos(3*t+pi/2);

for i = 1:length(t)
    scatter(x(i),y(i));
    hold on;
%     scatter(x(i),0);
%     scatter(y(i),0);
    plot([-2 2],[0 0]);%画坐标轴
    plot([0 0],[-2 2]);%画坐标轴
    axis equal;
    axis([-2 2 -2 2]);%防止抖动
    M(i) = getframe;%保存图像
%     hold off;
end
movie(M)%可以在命令行直接调用

The animation can be generated by a for loop, where the accuracy of the animation is controlled by time t. The smaller the step length of t, the smoother the movement of the points in the track animation.
For the readability of the image, we drew the x-axis and y-axis, and projected when it left the point moving.
If we only want to watch a series of trajectories generated when a point moves, we draw the point at a certain moment, and then use the hold on command.

Track
Finally, we can directly call moive (M) on the command line to play the picture matrix we saved earlier.
2

Published 84 original articles · won 18 · views 5805

Guess you like

Origin blog.csdn.net/qq_44486550/article/details/105362316