% -----------------------------------------------------
% trajectorytheta.m
% -----------------------------------------------------
% A program used to test function projectiletrajectory.m
% Compute the x and y distances as a function of time for a 
% projectile given initial velocity, but varying launch angle. 
% -----------------------------------------------------
% Notes: Note the use of global variable g.  
% -----------------------------------------------------
% Copyright and license details available at matlabmarina.com
%------------------------------------------------------

clear;
clc;

% define global variables
global g
g = 32.2;     % acceleration due to gravity in ft/s^2

% Define inputs
v_initial = 200;  % initial velocity in ft/s
time = 0.00 : 0.01 : 20.00;        % time in seconds

% Calculute the trajectory - distance along x and y - and plot graphs on
% same figure
figure(1)
for theta = 20 : 10 : 90
    [y, x] = projectileTrajectory(v_initial,theta, time);
    plot(x,y);
    hold on;
end

axis([0 1300 0 700]);       % set limits on the axis
xlabel('distance along x in ft');
ylabel('distance along y in ft');
title('trajectories with launch angles 20,30,40...90 degrees');
grid;
