Skip to content

Commit

Permalink
Create projectile.m
Browse files Browse the repository at this point in the history
  • Loading branch information
dnb13003 committed Jan 31, 2017
1 parent 0204572 commit 733d853
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions HW1/projectile.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function h=projectile(v_mag,theta)
%input inital velocity v_mag
%input theta
angle=theta*(pi/180); %Converts the angle into radians
g=9.81; %acceleration due to gravity
x_position=2.37;%max x-position where the height will be calculated
hi=1.72; %height where the dart begins its projectile motion
vy=v_mag*sin(angle); %inital velocity in the y direction
vx=v_mag*cos(angle); %inital velocity in the x direction
t_air=x_position/vx; %The total flight time in seconds
y_d=(vy*t_air)-(.5*g*(t_air.^2)); %the y position not including the inital height
h=y_d+hi %Final height after including the inital height before thrown


%Pull function setdefaults
setdefaults
%plotting points
t= 0:.01:t_air; %range for the time from 0 to end of flight, space .01
x=vx*t %calculating x position
y_d=(vy*t)-(.5*g*(t.^2));%y position without inital height
y=y_d+hi %calculating y position
%Ploting x and y points
plot(x,y)
%axis labels and title
xlabel('x position')
ylabel('y position')
title('Projectile Motion of Darts')
end

0 comments on commit 733d853

Please sign in to comment.