Same function as tempConvert, demonstrating use of functions instead of inline code. tempConvert1 Takes input in degrees C, K, F, or R. Returns type selected. USAGE: tempConvert1([0 32 273 298],'k','f') ans = -459.4000 -401.8000 32.0000 77.0000 history: v1.0 by R.Sonnenfeld, 9/4/2006
function [ Tout ] = tempConvert1( Tin,inDegrees,outDegrees ) %Same function as tempConvert, demonstrating use of functions instead of inline code. %tempConvert1 Takes input in degrees C, K, F, or R. %Returns type selected. %USAGE: %tempConvert1([0 32 273 298],'k','f') %ans = % -459.4000 -401.8000 32.0000 77.0000 % %history: v1.0 by R.Sonnenfeld, 9/4/2006 % global DEBUG DEBUG=0; inDegrees=upper(inDegrees); %Convert strings to upper case to make fewer case statements 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 K=anyToKelvin(Tin,inDegrees) Tout=kelvinToAny(K,outDegrees) end