function a = rocketAcceleration(z,v,t)
% Find the acceleration of a rocket with initial mass m0=4e5kg, 
% dm/dt=-200kg/s (for t<25min), and gas exhaust velocity vg=2.5km/s.
% Input:
%   z   : position (height) in m
%   v   : velocity (m/s)
%   t   : time since liftoff (s)
% Output:
%   a   : acceleration (m/s^2)

% Set internal parameters
m0 = 4e4;      % initial mass (kg)
dmdt = -200;   % propellant burn rate (kg/s)
vg = 2.5e3;    % gas exhaust velocity (m/s)
tmax = 3*60;   % propellant duration (s)
g = 9.8;       % gravitational acceleration (m/s)

% Find acceleration
if t<=tmax
  f = abs(dmdt)*vg;
  m = m0+dmdt*t;
  a = (f-m*g-dmdt*v)/m;
else
  a = -g;
end

end
