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.
19 lines (18 sloc)
1.01 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 h=projectile(v_mag,theta) %Define v_mag with meters/second and angle theta in degrees | |
angle_radians = theta.*(0.01745329251); %convert angle to radians | |
X_o = 2.37; %Define distance in x direction | |
Y_o = 1.72; %Define intial height in y direction | |
g = 9.81; %Define gravity constant | |
Vx = v_mag*cos(angle_radians); %Define velocity in x direction | |
Vy = v_mag*sin(angle_radians); %Define velocity in y direction | |
t = X_o/(Vx); %Define scalar time | |
h = Y_o+(Vy)*t-(1/2)*g*(t^2); %Function for height | |
fprintf('The height is %f\n',h) %Display of calculated height | |
time_interval = 0:0.01:t; %Vector form of time | |
X_interval = v_mag*cos(angle_radians)*(time_interval); %Vector form of x interval | |
Y_interval = Y_o+Vy*sin(angle_radians)*time_interval-(1/2)*g*(time_interval.^2); %Vector form of y interval | |
setdefaults %set defaults | |
plot(X_interval,Y_interval); %plot function in terms of x and y vectors | |
xlabel('Distance(m)'); %horizontal label | |
ylabel('Distance(m)'); %vertical label | |
title('Dart Data Dilemma'); %Alliteration at its finest |