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