forked from sed12008/ME3255S2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |