How do I write a projectile motion code that is automated and plots motion given certain heights, angles and initial velocity?
Mostra commenti meno recenti
I need help writing a "for" or "while" code that is automated in a sense where it plots the projectile's motion given the heights, angles and initial velocity. I am not including drag or rolling after the initial launch since I want to learn the basics.
2 Commenti
James Tursa
il 2 Feb 2022
What have you done so far? What specific problems are you having with your code?
Paul Jones
il 2 Feb 2022
Risposta accettata
Più risposte (1)
David Hill
il 2 Feb 2022
function d = projMotion(velocity,height,angle)
Vyi=velocity*sind(angle);
g=9.81;
tmax=(2*Vyi/g+sqrt((2*Vyi/g)^2+8*height/g))/2;
t=0:.001:tmax;
d=height+Vyi*t-.5*g*t.^2;
plot(t,d)
end
4 Commenti
Paul Jones
il 3 Feb 2022
David Hill
il 3 Feb 2022
velocity=16;
figure;
hold on;
for height=1:2
for angle=30:15:60
d=projMotion(velocity,height,angle);
end
end
Paul Jones
il 3 Feb 2022
Edward
il 15 Feb 2023
Any chance you can explain where you got the tmax from? Im struggling to recreate it and dont know why its 8*height/g
Thanks!
Categorie
Scopri di più su 2-D and 3-D Plots 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!


