Undefined function or variable 'Tw'

Okay I am trying to build a function and execute it and I keep getting an error. Any help would be appreciated.
function[Td,RH]=Dewpoint(T,Tw,Psta)
Es=6.112^((17.67*T)/(T+243.5)); Ew=6.112^((17.67*Tw)/(Tw+243.5));
E=Ew-(Psta*(T-Tw))*0.00066*(1+0.00115*Tw); RH=100*(E/(Es)); Td=(243.5*log(E/6.112))/(17.67-log(E/6.112)); end
That's my function. When I try to execute it in a new script file I get this error.
>> [Td,RH]=Dewpoint(25,19,985); fprintf('For a wet bulb temperature of %.2f, dry point temperture of %.2f and pressure of %.2f, the dew point temperature and relative humidity are %.2f and %.2f.\n',Tw,T,Psta,Td,RH) Undefined function or variable 'Tw'.
Help is greatly appreciated as I am new to using Matlab.

Antworten (1)

Honglei Chen
Honglei Chen am 7 Sep. 2017

0 Stimmen

Looks like the issue is more on the fprintf line, not the function call. Indeed you are using variable name Tw in fprintf without defining it.
HTH

Kategorien

Mehr zu Performance and Memory finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Sep. 2017

Beantwortet:

am 7 Sep. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by