一.ball.m
clear
vx=input('please input the speed ration of Vx and Vi:');
k=input('coefficient of rebound(<1):');
if k>=1 return,end
tm=(1+k)/(1-k);
xm=vx*tm;
figure
plot([0,xm],[0,0],'LineWidth',3)
grid on
axis equal
axis([0,xm,0,1])
title('Trajectoey of ball','FontSize',16)
xlabel('horizontal distance(m)','FontSize',16)
ylabel('Vertical height(m)','FontSize',16)
dt=0.001;
tm=1;
t=0:dt:tm;
x=2*vx*t;
y=1-t.^2;
i=0;
hold on
while tm>0.01
comet(x,y)
plot(x,y,'LineWidth',2)
i=i+1;
tm=2*k.^i;
t=0:0.001:tm;
x=x(end)+2*vx*t;
y=2*k^i*t-t.^2;<