annotate examples/private/secs2hms.m @ 1:7750624e0c73 version0.5

(none)
author idamnjanovic
date Thu, 05 Nov 2009 16:36:01 +0000
parents
children
rev   line source
idamnjanovic@1 1 function [h,m,s] = secs2hms(t)
idamnjanovic@1 2 %SECS2HMS Convert seconds to hours, minutes and seconds.
idamnjanovic@1 3 % [H,M,S] = SECS2HMS(T) converts the specified number of seconds T to
idamnjanovic@1 4 % hours, minutes and seconds. H and M are whole numbers, and S is real.
idamnjanovic@1 5 %
idamnjanovic@1 6 % Example: Estimate the remaining time of a loop
idamnjanovic@1 7 %
idamnjanovic@1 8 % n = 10; tic;
idamnjanovic@1 9 % for i = 1:n
idamnjanovic@1 10 % pause(1);
idamnjanovic@1 11 % [h,m,s] = secs2hms( (n-i)*toc/i );
idamnjanovic@1 12 % printf('estimated remaining time: %02d:%02d:%05.2f',h,m,s);
idamnjanovic@1 13 % end
idamnjanovic@1 14
idamnjanovic@1 15
idamnjanovic@1 16 % Ron Rubinstein
idamnjanovic@1 17 % Computer Science Department
idamnjanovic@1 18 % Technion, Haifa 32000 Israel
idamnjanovic@1 19 % ronrubin@cs
idamnjanovic@1 20 %
idamnjanovic@1 21 % April 2008
idamnjanovic@1 22
idamnjanovic@1 23
idamnjanovic@1 24 s = t;
idamnjanovic@1 25 h = fix(s/3600);
idamnjanovic@1 26 s = rem(s,3600);
idamnjanovic@1 27 m = fix(s/60);
idamnjanovic@1 28 s = rem(s,60);