Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: MatLab Output Argument Error
Replies: 2   Last Post: Nov 6, 2012 9:45 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 James Posts: 4 Registered: 11/1/12
MatLab Output Argument Error
Posted: Nov 6, 2012 2:05 AM
 Plain Text Reply

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)*(T1-32)+273;
T_H= (5/9)*(T2-32)+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_H-T_C));
if COP >= 0
COP=(T_C/(T_H-T_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_C-T_H);
if COP>=0
Qdot=h*A*(T_C-T_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.

Date Subject Author
11/6/12 James
11/6/12 Rick Branch
11/6/12 Steven Lord

© The Math Forum at NCTM 1994-2018. All Rights Reserved.