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/projectileV2.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
24 lines (23 sloc)
1.33 KB
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 [ 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 |