空气阻力不恒定的弹丸运动

时间:2018-12-30 14:18:25

标签: matlab projectile

我需要模拟“巴黎大炮”的弹丸运动。我需要考虑空气阻力随海拔高度的变化,公式如下:

p = p0*exp(-y/y0)

其中y0 = 1000m

阻力为:

Fd = -0.5*C*p*A*v^2

到目前为止,我的代码如下:

clc
clear
m = 94;
A = pi*(.21)^2;
C = .12;
p0 = 1.225;
g = 9.81;
%Initial Conditions
dt = .001;
x(1) = 0;
y(1) = 0;
v = 10000; 
angle = 20;
vx = v*cosd(angle)
vy = v*sind(angle);
t(1) = 0 ;
i = 1;
y0 = 1000;
while min(y)> -.001
    p = p0*exp(-y/y0)
    Drag = p*C*A/2*v^2
    ax = -(Drag/m)*(vx*vx+vy*vy)^0.5*vx;
    ay = -g-(Drag/m)*(vx*vx+vy*vy)^0.5*vy;
    vx = vx+ax*dt;
    vy = vy+ay*dt;
    x(i+1) = x(i)+vx*dt+.5*ax*dt^2;
    y(i+1) = y(i)+vy*dt+.5*ay*dt^2;
    t(i+1) = t(i)+dt;
    i = i+1;
end
  plot(x,y,'-')
  xlabel('x distance (m)')
  ylabel('y distance (m)')
  pause(0.001);

我在这里无法获得正确的模拟。如果我将阻力作为常数并将其置于初始条件下,则效果很好。但是,当我将其放在while循环中时,整个模拟给了我绝对的废话。感谢您的帮助。

0 个答案:

没有答案