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

3 vues (au cours des 30 derniers jours)
Amit
Amit le 13 Avr 2013
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')

Réponses (2)

Jürgen
Jürgen le 14 Avr 2013
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 commentaires
Jürgen
Jürgen le 15 Avr 2013
while horFlightDist < 1000
do something
end
Amit
Amit le 15 Avr 2013
Thanks. I tried doing that but I get a funny looking graph. I'm also not sure where to put the while loop?

Connectez-vous pour commenter.


Amit
Amit le 15 Avr 2013
can anyone help? thanks.

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by