Home > published > anyToKelvin.m

anyToKelvin

PURPOSE ^

Takes input in degrees C, K, F, or R, and returns temperature in Kelvin.

SYNOPSIS ^

function [ K ] = anyToKelvin( Tin,inDegrees )

DESCRIPTION ^

Takes input in degrees C, K, F, or R, and returns temperature in Kelvin.
USAGE:
anyToKelvin([0 32 273 -298 -40],'F')
ans =
 255.2222  273.0000  406.8889   89.6667  233.0000

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

function [ K ] = anyToKelvin( Tin,inDegrees )
%Takes input in degrees C, K, F, or R, and returns temperature in Kelvin.
%USAGE:
%anyToKelvin([0 32 273 -298 -40],'F')
%ans =
% 255.2222  273.0000  406.8889   89.6667  233.0000

inDegrees=upper(inDegrees);
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

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