clear; clc;   % clear variables and clear screen.

t = 5;

% define some variables
a  = -9.8; % m/s^2
vo = 20;   % m/s
theta = 39 * pi/180;   % convert to radians

xo = 0;
yo = 0;

% velocity components
vxo = vo * cos(theta);
vyo = vo * sin(theta);

% solve for position
x = xo+vxo*t;
y = yo + vyo*t + 1/2 * a * t^2;

% solve for velocity.
vx = vxo;
vy = vyo + a*t;

v = sqrt( vx^2 + vy^2 );

% display the results
disp('x position (m):');
disp(x);
disp('y position (m):');
disp(y);
disp('velocity magnitude (m/s):');
disp(v);