Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
why isn't my code iterating?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
the problem i am having is that my velocity while loop is not ending. it just iterates forever and never changes in value for any of the parameters within the loop.
I know there is a lot of but the problem is specifically within the while loop, just wanted to add it all so all variables are known.
%problem 1
%given parameters----------------------------------------------------------
g=9.81; %m/s^2
mT0=190854;%kg
WT0=mT0*g; %N
SLG=.887; %m^2
u_roll=.023;
Sw=367.7; %m^2
CLmax=1.84;
b=50.4; %m
CDflap=.02;
CLG=.65*CLmax;
Hobst_given=50; %ft
H_obst=Hobst_given*.3048;%m <-------feet to meters
Hw=4.072; %m
CDpara=.018;
gammaCL=15;
T0=178000*3; %N
%density conversions-------------------------------------------------------
denisty1=.002106; %slugs/ft^3
density=1.085; %kg/m^3
densitysl1=.002377; %slugs/ft^3
densitysl=1.2251; %kg/m^3
sigma=density/densitysl;
%aspect ratio and effiective AR--------------------------------------------
AR=b^2/Sw;
AReff=AR*sqrt(b/(2*Hw));
%e value-------------------------------------------------------------------
e=2/(2-AReff+sqrt(4+AReff^2));
%drag coefficients---------------------------------------------------------
CD_ig=CLG^2/(pi*e*AReff);
CD0LG=((3.23*WT0)/1000)*(SLG/Sw);
%CD flap is given as .02
Cdg=CD_ig+CDflap+CDpara+CD0LG;
%a)
%ground roll for a jet-----------------------------------------------------
SG=(WT0/(sigma*Sw*CLG))*((T0/WT0)^-1)*((g*density)^-1);
%iteration for velocity----------------------------------------------------
n=1;
V(n)=0;
q(n)=.5*V(n)^2*density;
Daero(n)=Cdg*q(n)*Sw;
L(n)=CLG*q(n)*Sw;
Droll(n)=u_roll*(WT0-L(n));
Fx(n)=T0-Daero(n)-Droll(n);
ax(n)=g*(Fx(n)/WT0);
t(n)=0;
delt=.01; %sec
while V(n)<1.2*120
n=n+1;
t(n)=t(n-1)+delt;
V(n)=V(n-1)+ax(n-1)*delt;
q(n)=.5*V(n)^2*density;
Daero(n)=Cdg*q(n)*Sw;
L(n)=CLG*q(n)*Sw;
Droll(n)=u_roll*(WT0-L(n));
Fx(n)=T0-Daero(n)-Droll(n);
ax(n)=g*(Fx(n)/WT0);
end
%velocity------------------------------------------------------------------
V=V(end);
0 Kommentare
Antworten (1)
Jeremy
am 26 Feb. 2020
Bearbeitet: Jeremy
am 26 Feb. 2020
Your while loop is converging on a value that is less than 1.2*120.
Consider adding an additional parameter that breaks the loop when the solution has converged.
error = 1;
while V(n)<1.2*120 && error > 1e-10
n=n+1;
t(n)=t(n-1)+delt;
V(n)=V(n-1)+ax(n-1)*delt;
q(n)=.5*V(n)^2*density;
Daero(n)=Cdg*q(n)*Sw;
L(n)=CLG*q(n)*Sw;
Droll(n)=u_roll*(WT0-L(n));
Fx(n)=T0-Daero(n)-Droll(n);
ax(n)=g*(Fx(n)/WT0);
if n < 2
error = 1;
else
error = abs(V(n) - V(n-1));
end
end
1 Kommentar
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!