Home > air_sea > hms2h.m

hms2h

PURPOSE ^

HMS2H: converts hours, minutes, and seconds to hours.

SYNOPSIS ^

function [hours]=hms2h(h,m,s);

DESCRIPTION ^

 HMS2H: converts hours, minutes, and seconds to hours.
 [hours]=HMS2H(h,m,s) converts hours, minutes, and seconds to hours

   INPUT:  h  - integer hours
           m  - minutes
           s  - secs

   OUTPUT: hours - decimal hours

   Usage:  [hours]=hms2h(h,m,s);   or [hours]=hms2h(hhmmss);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [hours]=hms2h(h,m,s);
0002 % HMS2H: converts hours, minutes, and seconds to hours.
0003 % [hours]=HMS2H(h,m,s) converts hours, minutes, and seconds to hours
0004 %
0005 %   INPUT:  h  - integer hours
0006 %           m  - minutes
0007 %           s  - secs
0008 %
0009 %   OUTPUT: hours - decimal hours
0010 %
0011 %   Usage:  [hours]=hms2h(h,m,s);   or [hours]=hms2h(hhmmss);
0012 
0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0014 % 3/8/97: version 1.0
0015 % 8/5/99: version 2.0
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 if nargin== 1,
0019    hms=h;
0020    h=floor(hms/10000);
0021    ms=hms-h*10000;
0022    m=floor(ms/100);
0023    s=ms-m*100;
0024    hours=h+m/60+s/3600;
0025 else
0026    hours=h+(m+s/60)/60;
0027 end
0028 
0029

Generated on Thu 26-Apr-2007 12:23:13 by m2html © 2003