Home > . > sec2hms.m

sec2hms

PURPOSE ^

function [hour, minute, second] = sec2hms(sec)

SYNOPSIS ^

function hms = sec2hms(sec)

DESCRIPTION ^

function [hour, minute, second] = sec2hms(sec)
SEC2HMS  Convert seconds to hours, minutes and seconds.

   [HOUR, MINUTE, SECOND] = SEC2HMS(SEC) converts the number of seconds in
   SEC into hours, minutes and seconds.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function hms = sec2hms(sec)
0002 %function [hour, minute, second] = sec2hms(sec)
0003 %SEC2HMS  Convert seconds to hours, minutes and seconds.
0004 %
0005 %   [HOUR, MINUTE, SECOND] = SEC2HMS(SEC) converts the number of seconds in
0006 %   SEC into hours, minutes and seconds.
0007 
0008 %   Author:      Peter J. Acklam
0009 %   Time-stamp:  2002-03-03 12:50:09 +0100
0010 %   E-mail:      pjacklam@online.no
0011 %   URL:         http://home.online.no/~pjacklam
0012 
0013    hour   = fix(sec/3600);      % get number of hours
0014    sec    = sec - 3600*hour;    % remove the hours
0015    minute = fix(sec/60);        % get number of minutes
0016    sec    = sec - 60*minute;    % remove the minutes
0017    second = sec;
0018    hms = [num2str(hour,'%02g') ':' num2str(minute,'%02g') ':' num2str(second,'%02g')];

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003