function [ Tout ] = tempConvert( Tin,inDegrees,outDegrees )
global DEBUG
DEBUG=0;
inDegrees=upper(inDegrees);
outDegrees=upper(outDegrees);
if DEBUG==1
fprintf('Input temperature was %6.1f\n',Tin);
fprintf('Units input are %3s\n',inDegrees);
fprintf('Units requested are %3s\n',outDegrees);
end
switch inDegrees
case('K')
K=Tin;
case('C')
K=Tin+273;
case('R')
F=Tin-459.67;
K=((5/9)*(F-32))+273;
case('F')
K=((5/9)*(Tin-32))+273;
otherwise
warning(['Invalid input units ',inDegrees])
end
if DEBUG==1 fprintf('Temperature in Kelvin is %6.1f\n',K); end
switch outDegrees
case('K')
Tout=K;
case('C')
Tout=K-273;
case('F')
Tout=(9/5)*(K-273)+32;
case('R')
F=(9/5)*(K-273)+32;
Tout=F+459.67;
otherwise
warning(['Invalid output units ',outDegrees])
end