Skip to content
Permalink
85a80e6bad
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
24 lines (23 sloc) 1.33 KB
function [ height ] = projectileV2( v_mag,theta )
%Pojectile (Calculate the height of a dart projectile)
% Input variables velocity and theta are used to find final height.
%--------- Assign Constants -----------------------------------------------
d = 2.37; %distance to dartboard
h0 = 1.72; %initial height of dart
a = 9.81; %acceleration due to gravity
%--------- Operations -----------------------------------------------------
vx = v_mag*cosd(theta); %calculate x-component of velocity
vy = v_mag*sind(theta); %calculate y-component of velocity
x = linspace(0,d,d*100+1); %create row vector for x values
t = x/vx; %calculate time at given x value
height = h0+vy*t+0.5*-a*(t.^2); %calculates height for given time
%--------- Plot of Data -----------------------------------------------
set(0, 'defaultAxesFontSize',16) %set defaults for text in plot
set(0, 'defaultTextFontSize',14)
set(0, 'defaultLineLineWidth',3)
plot(x,height,'c') %Plot x vs height
xlabel('X-Position of Dart (meters)') %Labels for axis and title
ylabel('Dart Height (meters)')
title('Projectile Path of Dart')
xlim([0,d]) %Limit domain to [0,d]
end