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.
added projectile
- Loading branch information
Patrick Begley
authored and
Patrick Begley
committed
Feb 16, 2017
1 parent
f6b83ce
commit eb2a710
Showing
3 changed files
with
54 additions
and
1 deletion.
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,t_linear,y] = projectile(v_mag,theta) | ||
% Function that takes the initial velocity magnitude and the angle of | ||
% launch of the projectile and calculates the height at 2.37m away from the | ||
% initial position from an initial height of 1.72m. | ||
% Inputs: v_mag, theta | ||
% Output: h | ||
% | ||
% Also plots the path to a distance of 2.37m. | ||
|
||
i = 1; | ||
x0 = 2.37; | ||
y0 = 1.72; | ||
g = -9.81; | ||
|
||
t = x0/(v_mag*cos(theta)); | ||
t_linear = 0:0.01:t; | ||
y = zeros(1,length(t_linear)); | ||
h = y0 + x0/cos(theta) + 0.5*g*(x0/(v_mag*cos(theta)))^2; | ||
|
||
for t = t_linear | ||
y(i) = y0 + v_mag*t + 0.5*g*t^2; | ||
i = i + 1; | ||
end | ||
|
||
plot(t_linear, y) | ||
|
||
end | ||
|
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,26 @@ | ||
function [h,t_linear,y] = projectile(v_mag,theta) | ||
% Function that takes the initial velocity magnitude and the angle of | ||
% launch of the projectile and calculates the height at 2.37m away from the | ||
% initial position from an initial height of 1.72m. | ||
% Inputs: v_mag, theta | ||
% Output: h | ||
% | ||
% Also plots the path to a distance of 2.37m. | ||
|
||
x0 = 2.37; | ||
y0 = 1.72; | ||
g = -9.81; | ||
|
||
t = x0/(v_mag*cos(theta)); | ||
t_linear = 0:0.1:t; | ||
y = zeros(length(t_linear)); | ||
h = y0 + x0/cos(theta) + 0.5*g*(x0/(v_mag*cos(theta)))^2; | ||
|
||
for t = t_linear | ||
y() = y0 + v_mag*t + 0.5*g*t^2; | ||
end | ||
|
||
plot(t_linear, y) | ||
|
||
end | ||
|