increasing the launch angle of projectile so it reaches a certain distance

조회 수: 5(최근 30일)
I am currently doing a school project where i have to plot the trajectory of a projectile launched from the ground with initial speed u, and angle theta above the horizontal. The projectile has to hit a target of a horizontal distance D=10000m away once it has reached the ground. I have used an initial guess of theta=pi/12 as the angle, so that the projectile does not reach D. The program should then automatically pick a new value of theta by increasing theta from pi/30 in steps dtheta=theta/100 until the target is overshot. A parachute is deployed at t_pchute=15 seconds.
How do I increase the angle iteratively such that the projectile reaches the target? I was told to use theta(i+1)=atan(vy(i)/vx(i)), but i'm not sure why. If you have time, please help me.
%Constants
D=10000;%m
u=600;%m/s
m=50;%kg
t_pchute=15;%s
g=9.81;%m/s^2
a_proj=0.01;%m^2
a_pchute=0.05;%m^2
C_proj=0.4;
C_pchute=1.2;
p0=1.207;%kg/m^3
theta=pi/12;
dtheta=theta/100;
%initial conditions
x=0;
i=0;
t=0;
y=0;
dt=0.1;
p=p0;
vx=u*cos(theta);
vy=u*sin(theta);
v=sqrt(vx.^2+vy.^2);
for i=1:1000
Fa(i+1)=0.5*p(i)*C_proj*a_proj*v(i);
Fp(i+1)=0.5*p(i)*C_pchute*a_pchute*v(i);
if t<t_pchute
ax(i+1)=-((Fa(i)*cos(theta(i)))/m)*vx(i);
ay(i+1)=-g-(((Fa(i)*sin(theta(i)))/m)*vy(i));
else
ax(i+1)=-((Fp(i)*cos(theta(i)))/m)*vx(i);
ay(i+1)=-g-(((Fp(i)*sin(theta(i)))/m)*vy(i));
end
vx(i+1)=vx(i)+(dt.*ax(i));
vy(i+1)=vy(i)+(dt.*ay(i));
v(i+1)=sqrt(vx(i).^2+vy(i).^2);
x(i+1)=x(i)+(dt.*vx(i));
y(i+1)=y(i)+(dt.*vy(i));
p(i+1)=p0*(1-2.333e-5*y(i+1)).^5;
theta(i+1)=atan(vy(i)/vx(i));
t=t+dt;
if y(i+1)<0
break
end
end
plot(x,y),grid
xlabel('Distance/[m]')
ylabel('Height/[m]')
title('Projectile Trajectory')

답변(2개)

Jürgen
Jürgen 2013년 4월 14일
Hi, I admint I did not check all your code, but
if you want something like:
theta= Value;
thetaStep= StepValue;
for i= 1:someValue
Theta= Theta+ StepValues*(i-0);
do something with theta
end
then I find it strange that you use Theta/100 as step value because your step is then a function of Theta, or is that done deliberately?
R,J
  댓글 수: 3
Amit
Amit 2013년 4월 15일
Thanks. I tried doing that but I get a funny looking graph. I'm also not sure where to put the while loop?

댓글을 달려면 로그인하십시오.


Amit
Amit 2013년 4월 15일
can anyone help? thanks.

범주

Find more on Flight Parameters and Quaternion Math 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!

Translated by