%% Projectile Path Over Time
% This example shows how to display the path of a projectile as a function
% of time using a three-dimensional quiver plot. 
%
% Show the path of the following projectile using constants
% for velocity and acceleration, |vz| and |a|.
% 
% $$z(t) = v_zt + \frac{at^2}{2}$$

% Copyright 2015 The MathWorks, Inc.


vz = 10; % velocity constant
a = -32; % acceleration constant          

%%
% Calculate |z| as the height as time varies from 0 to 1.
t = 0:.1:1;
z = vz*t + 1/2*a*t.^2;

%%
% Calculate the position in the _x_-direction and _y_-direction.
vx = 2;
x = vx*t;

vy = 3;
y = vy*t;

%%
% Compute the components of the velocity vectors and display the vectors
% using a 3-D quiver plot. Change the viewpoint of the axes to |[70,18]|.

u = gradient(x);
v = gradient(y);
w = gradient(z);
scale = 0;

figure
quiver3(x,y,z,u,v,w,scale)
view([70,18])