Projectile motion without drag
Show older comments
I've been trying to figure out how to make this script work for matlabs, but am getting a return that says "Index exceeds the number of array elements (1).. ..x(k+1)=Vx(k)*delt;" if anymore explantion if needed let me know (script below). Thank you!
%Projectile motion with and without drag
%Constants
gc=32.174;
g=-32.174;
v0=100;
ang=30;
ang=ang*pi/180;
mass=0.4;
weight=0.4;
area=11.34;
cd=0.6;
delt=0.1;
x0=0;
y0=0;
%Projectile motion without drag
x(1)=0;
y(1)=0;
Vx=v0*cos(ang);
Vy=v0*sin(ang);
k=1;
while y(k)>=0
Vy(k+1)=Vy(k)+g*delt;
y(k+1)=Vy(k)*delt;
x(k+1)=Vx(k)*delt;
k=k+1;
end
Xmax=max(x)
Ymax=max(y)
%with Drag%
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!