フィルターのクリア

While loop variables are returning NaN ... Why?

2 ビュー (過去 30 日間)
Hawki005
Hawki005 2019 年 3 月 23 日
コメント済み: Hawki005 2019 年 4 月 2 日
Hi, now i understand it is common for NaN to be outoputted when 0 is divided by 0 or inf by inf etc, however i cannot understant why this section of code returns NaN for the variable ew.
Xt and the other following variables produce NaN but this will be because they are a function of ew.
Am I incorrectly using the while loop function
fThetaWater = 2;
while 1
ew = (1.9226*10^-7*(fThetaWater^4))+(2.4545*10^-5*(fThetaWater^3))+(1.4224*10^-3*(fThetaWater^2))+(0.044436*(fThetaWater))+0.61094;
Xt = 1+0.622*(Lv/(Patm/Cp))*((ea-ew)/(ThetaAir-fThetaWater));
ThetaDrop = ThetaAir+((fThetaWater-ThetaAir)*exp(-((6*Nu*Ka)/(rhowater*Cw*(d^2)))*Xt*Tau));
if abs(fThetaWater-ThetaDrop)<0.00010
break;
else
fThetaWater = ThetaDrop;
end
end
  2 件のコメント
dpb
dpb 2019 年 3 月 23 日
fThetaWater = 2;
b= [1.9226E-7,2.4545E-5,1.4224E-3,0.044436,0.61094]; % ew poly coefficients
while 1
ew=polyval(b,fThetaWater);
Xt = 1+0.622*(Lv/(Patm/Cp))*((ea-ew)/(ThetaAir-fThetaWater));
ThetaDrop = ThetaAir+((fThetaWater-ThetaAir)*exp(-((6*Nu*Ka)/(rhowater*Cw*(d^2)))*Xt*Tau));
if abs(fThetaWater-ThetaDrop)<0.00010
break;
else
fThetaWater = ThetaDrop;
end
end
I'm guessing it's probably other way round -- Xt or ThetaDrop are the culprits and they then propogate to fThetaWater and ew
We don't have the rest of the constants to duplicate but put in an m-file and set
dbstop if naninf
and you'll find who's the first culprit
Hawki005
Hawki005 2019 年 4 月 2 日
Perfect Thank you!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by