Projectile motion of a cannonball(without drag) - calculating the route, range, height and time it will spend in the air of a cannonball fired with a certain force

4 visualizaciones (últimos 30 días)
A force of 1000 newtons is applied to the cannonball. But the code does not simulate correctly. I could not find my fault. I would be very grateful if you could help. Thanks.
clear;
clc;
g=9.81;
m=1;
F=1000;
dt=0.1;
t=0;
angle=45;
Fx=cosd(angle)*F;
Fy=sind(angle)*F;
axold=Fx/m;
ayold=Fy/m;
vx=0;
vy=0;
x=0;
y=0;
while min(y)>-0.001
t=t+dt;
ax=0;
ay=-g;
if (t==0.1)
vx=vx+dt*(axold)/2;
else
vx=vx+dt*(ax)/2;
end
if (t==0.1)
vy=vy+dt*(ayold)/2;
else
vy=vy+dt*(ay+ayold)/2;
end
if (t==0.1)
x=x+vx*dt+dt*dt*(axold)/2;
else
x=x+vx*dt+dt*dt*(ax+axold)/2;
end
if (t==0.1)
y=y+vy*dt+dt*dt*(ayold)/2;
else
y=y+vy*dt+dt*dt*(ay+ayold)/2;
end
Height=max(y);
end
plot(x,y)
xlabel('x distance (m)')
ylabel('y distance (m)')
title('Cannonball Path')
  1 comentario
Image Analyst
Image Analyst el 9 de Mayo de 2021
@TOLGAHAN VARISLI, deleting questions after they've been answered is very much frowned upon and may limit the number of answers you get in future questions.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 8 de Mayo de 2021
See my attached projectile demo. It has variables for just about everything you could want to specify and computes just about everything you can possibly think of.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by