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!