MATLAB: Function keeps getting errors, how to fix

embedded matlab functionerrorfunctionMATLABmatlab functiontwo input function

I have to make a function that takes 2 inputs to find relative humidity.
This is my attempt:
function RH = RelHum(Tdb, Twb)
%finds relative humidityIf the
ftoc = @(n) ((n-32)*(5/9));
%finding pressures
svp = exp(1)^((16.78*ftoc(Tdb) – 116.9)/(ftoc(Tdb) + 237.3));
vp = exp(1)^((16.78*ftoc(Twb) – 116.0)/(ftoc(Twb) + 273.3)) – 0.066858 *(1+ 0.00115*ftoc(Twb))*(ftoc(Tdb)-ftoc(Twb));
RH = vp/svp * 100;
end
The error just indicates a problem with the 'vp' line and highlights it in red.
This is the function I'm supposed to be using for vp ^^^^^^^^
I appricate any help you can give me, right now I'm pretty lost.

Best Answer

  • function RH = RelHum(Tdb, Twb)
    syms n % define the symbolic n
    ftoc = @(n) ((n-32)*(5/9));
    svp = exp(1)^((16.78*ftoc(Tdb) - 116.9)/(ftoc(Tdb) + 237.3));
    vp = exp(1)^((16.78*ftoc(Twb) - 116.0)/(ftoc(Twb) + 273.3)) - 0.066858 *(1+ 0.00115*ftoc(Twb))*(ftoc(Tdb)-ftoc(Twb));
    RH = vp/svp * 100;
    end
    Define the symbolic n inside the function before using ftoc