Skip to content
Permalink
7f991220b3
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
21 lines (21 sloc) 933 Bytes
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