% rocketTrajectory.m
% Solution to problem 2 of control 2
% J.M.Soler, Feb.14, 2022

% Set data
clear all
dt = 1;
tmax = 5*60;
z0 = 0;
v0 = 0;
m = 1;

% Solve Newton's equation
[z,v,a] = newtonRK(@rocketAcceleration, m, z0, v0, dt, tmax);
t = 0:dt:tmax;

fprintf('vmax= %8.3e m/s.  amax= %8.3e m/s^2\n',max(v),max(a))

% Plot trajectory
figure(11)
plot(t,z,'LineWidth',1.5)
xlabel('time (s)')
ylabel('height (m)')
set(gca,'FontSize',15)
grid on

figure(12)
plot(t,v,'LineWidth',1.5)
xlabel('time (s)')
ylabel('velocity (m/s)')
set(gca,'FontSize',15)
grid on

figure(13)
plot(t,a,'LineWidth',1.5)
xlabel('time (s)')
ylabel('acceleration (m/s^2)')
set(gca,'FontSize',15)
grid on

