MATLAB动态图画法-使用For命令实现重力加速度分叉

vx = 40;
T = 0.01;
t = 0:T:5;
x = vx*t;
y1 = -9.8*t.^2/2;
y2 = 9.8*t.^2/2;
figure()
for i=1:(length(x)-1)
axis([0,200,-100,100])
X = x(i:i+1);
Y1 = y1(i:i+1);
Y2 = y2(i:i+1);
plot(X,Y1);
hold on
plot(X,Y2);
hold on
pause(0.01)
end
figure()
for i=1:length(x)
comet(x(i),y1(i))
hold on
comet(x(i),y2(i))
hold on
end

x与y1,y2三个变量,x累加从左到右画图,

你可能感兴趣的:(MATLAB学习笔记)