Borrar filtros
Borrar filtros

While loop variables are returning NaN ... Why?

2 visualizaciones (últimos 30 días)
Hawki005
Hawki005 el 23 de Mzo. de 2019
Comentada: Hawki005 el 2 de Abr. de 2019
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 comentarios
dpb
dpb el 23 de Mzo. de 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
Hawki005
Hawki005 el 2 de Abr. de 2019
Perfect Thank you!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by