%%Vertical motion of a ball 
%
%g acceleration due to gravity (m/s^2)
%r number of timesteps
%v0 initial velocity (m/s)

g = 9.8;
r = 300;
v0 = 29.4;

%Ymax maximal height
%Tend the end time
%deltaT the time step

Ymax = v0^2/(2*g);
Tend = 2*v0/g;
deltaT = Tend/r;

%t time vector 
%y vector of y-coordinates

t = 0:deltaT:Tend;
y = -g/2*t.^2+v0*t;

figure(1)

for s=1:r+1
    plot(0,y(s),'o','MarkerFaceColor', 'r','MarkerSize',10);
    axis([-1 1 0 1.1*Ymax])
    drawnow
end
