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.
回答(1 个)
Honglei Chen
2017-9-7
0 个投票
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
类别
在 帮助中心 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!