clear; clc;
v0 = 0;
y0 = 0;
w0 = [v0 y0];
t0 = 0;
tF = 20;                % end time
timespan = [ t0 tF ];   % only two elements, first and last
[t_soln, w_soln] = ode45('parachuteODE2', timespan, w0);
v_soln = w_soln(:,1);
y_soln = w_soln(:,2);
plot( t_soln, v_soln,'.', t_soln, y_soln, '-' ); 
w_soln
y_soln(length(y_soln))

% 2.d) How far will the parachutist fall in 20 seconds?
time20 = length(t_soln);  % the last value in t is 20, time20 is the index
                     % of the last value
disp(['The last time value is: ', num2str(t_soln(time20))]) % just checking
disp(['In 20 seconds the parachutists falls ', num2str(y_soln(time20)), ...
      ' m'])
  
% How fast is he falling after 20 seconds?
disp(['After 20 seconds the parachutists is falling ', ...
      num2str(v_soln(time20)), ' m/sec'])
  
% 2.f) What is the value of the terminal velocity?
% Setting v'(t) = 0 and solving for v(t) we get that the steady-state
% value is v(t) = g*m/c_drag
g = 9.8;
m = 70;
cD = 10;
terminalV = g*m/cD;
disp(['The terminal velocity is ', num2str(terminalV), ' m/sec'])  