annotate Problems/private/secs2hms.m @ 39:8f734534839a

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