Plotting a projectile (it doesn't plot anything)
Mostra commenti meno recenti
disp (['not part of anything but i wrote this below and no matter what i do ' ...
' n/ i cant get it to plot, Please help me ' ...
'n/My original plan was to get it to plot in an animated ' ...
' n/format but id take anything if it works'])
close all %Closes all other windows associated with Matlab.
clear %Erases all existing variables.
clc %Clears the command window.
%% Input Data
disp ('What are the given Data')
prompt = 'What is the Initial Speed of the projectile in m/s?';
v0 = input (prompt);
prompt2 = 'What is the angle of the projectile in degrees?';
theta = input (prompt2);
prompt3 = 'What is the acceleration due to gravity in m/s^2?';
g = input (prompt3);
%%Calculations and those other sections can be used to display the calculated data
%% TODO
disp ('Given Data')
v = 0;
%% The horizontal component of the velocity.
disp ('Horizontal Velocity (HV)')
HV = v0*cosd(theta);
%% The vertical component of the velocity.
disp ('Vertical Velocity (VV)')
VV = v0*sind(theta);
%% The greatest height above ground attained by the shell.
disp ('Greatest height above ground in meters')
Vsy = abs((v^2 -(VV^2))/(2*g)); % abs() is used to make the value always postive.
%% Time Taken for the projectile to fall to the ground after reaching it's maximum height.
disp ('Time Taken in seconds (tt)')
tt = abs((v-VV)/g);
%% Total air time of the projectile.
disp ('Total Time (Tt)')
TT = tt*2;
T = linspace(0,TT);
%% Maximum Horivontal distance travelled by the projectile
disp ('Max Horizontal Distance')
Hsx = HV*T;
%% Pjectiles motion shown graphically
plot(Hsx, Vsy, 'b-', 'LineWidth', 3);
grid on;
grid minor
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!