Home > published > tempConvert1.m

tempConvert1

PURPOSE ^

Same function as tempConvert, demonstrating use of functions instead of inline code.

SYNOPSIS ^

function [ Tout ] = tempConvert1( Tin,inDegrees,outDegrees )

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Fri 07-Nov-2008 13:46:59 by m2html © 2005