increasing the launch angle of projectile so it reaches a certain distance
조회 수: 3 (최근 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
Walter Roberson
2013년 4월 13일
How does this question differ from http://www.mathworks.co.uk/matlabcentral/answers/71006-how-do-i-increase-the-angle-so-that-the-projectile-reaches-the-target and http://www.mathworks.co.uk/matlabcentral/answers/71143-so-stuck-please-help-how-do-i-find-the-correct-angle-for-the-graph-trajectory-of-my-projectile-mot ?
답변 (2개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Dialog Boxes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!