Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


James
Posts:
4
Registered:
11/1/12


MatLab Output Argument Error
Posted:
Nov 6, 2012 2:05 AM


This is my code:
function [COP,Qdot]=james(T1,T2)
temperature=menu('Temperature Scale','Fahrenheit','Centigrade','Kelvin','Rankine'); if temperature == 1 T_C= (5/9)*(T132)+273; T_H= (5/9)*(T232)+273; end if temperature == 2 T_C= T1+273; T_H= T2+273; end if temperature == 3 T_C= T1; T_H= T2; end if temperature == 4 T_C= (5/9)*(T1); T_H= (5/9)*(T2); end if T_H>=T_C COP=(T_C/(T_HT_C)); if COP >= 0 COP=(T_C/(T_HT_C)); fprintf('The coefficient of performance is %f \n',COP) else beep disp('Ensure that T_Cold is not greater than T_Hot and that T_Cold and T_Hot are equal or greater than zero when converted to Kelvin') end end if T_H>=T_C h=50; A=1; Qdot=h*A*(T_CT_H); if COP>=0 Qdot=h*A*(T_CT_H); fprintf('The heat transfer due to convection is %f W \n', Qdot) end else beep disp('Ensure that T1 is not greater than T2') end
end
I enter this command:
[COP,Qdot]=james(110,80);
and get:
Error in james (line 4) temperature=menu('Temperature Scale','Fahrenheit','Centigrade','Kelvin','Rankine');
Output argument "COP" (and maybe others) not assigned during call to "C:\Users\....".
Where am I going wrong in my code? I do not know where exactly I am going wrong because everything seems to be called for.



