While loop variables are returning NaN ... Why?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
dpb
le 23 Mar 2019
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
Réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!