Home > published > kelvinToAny.m

kelvinToAny

PURPOSE ^

kelvinToAnyany takes input in K, returns temp in C, K, F, or R.

SYNOPSIS ^

function [ Tout ] = kelvinToAny( K,outDegrees )

DESCRIPTION ^

kelvinToAnyany takes input in K, returns temp in C, K, F, or R.
USAGE:
kelvinToAny([273 0 100],'F')
ans =
   32.0000 -459.4000 -279.4000

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

function [ Tout ] = kelvinToAny( K,outDegrees )
%kelvinToAnyany takes input in K, returns temp in C, K, F, or R.
%USAGE:
%kelvinToAny([273 0 100],'F')
%ans =
%   32.0000 -459.4000 -279.4000
global DEBUG
DEBUG=0;
        
outDegrees=upper(outDegrees); 
if DEBUG==1 
    fprintf('Input temperature was %6.1f\n',K); 
    fprintf('Units requested are %3s\n',outDegrees);
end

switch outDegrees
    %Temperature has already been converted to Kelvin
    %Now convert it to selected scale for output.
    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

end

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