Info

此问题已关闭。 请重新打开它进行编辑或回答。

While loop and matrix not working together

1 次查看(过去 30 天)
I have a variable that is increasing at a step of .01. however when I run this when it gets to q(n) ir says that the indices on the left side are not compatible with the size of the right side.
density=[1.2251*.8:.01:1.2251]; %kg/m^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;
%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
error=1;
while V(n)<1.2*Vstall && 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

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by