Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
roots_and_optimization/projectile.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
21 lines (21 sloc)
933 Bytes
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
function h = projectile(v_mag,theta) | |
% The purpose of this function is to calculate the height that a dart will | |
% hit a wall with a given initial velocity and angle | |
g = -9.81; % Gravitational acceleration of the earth (m/s^2) | |
vel_x = v_mag*cos(theta); % X velocity of the dart | |
vel_y = v_mag*sin(theta); % Y velocity of the dart | |
t = 2.37/vel_x; % Finds time that dart is in the air | |
h = 1.72 + vel_y*t + .5*g*t^2; % Finds the height the dart hits the wall at | |
fprintf('The height of the dart is %i \n', h); | |
% The following code graphs the path of the dart over time utilizing the h | |
% equation found above. | |
%{ | |
t_graph = linspace(0,t,30); | |
position = 1.72 + vel_y.*t_graph + .5*g.*t_graph.^2; | |
plot(t_graph, position); | |
axis([0, t, min(position)-.05*min(position), max(position)+.05*max(position)]); | |
title('Position of a Dart over time'); | |
xlabel('t_{seconds}'); | |
ylabel('h_{meters}'); | |
%} | |
end |