idamnjanovic@60: function [h,m,s] = secs2hms(t) idamnjanovic@60: %SECS2HMS Convert seconds to hours, minutes and seconds. idamnjanovic@60: % [H,M,S] = SECS2HMS(T) converts the specified number of seconds T to idamnjanovic@60: % hours, minutes and seconds. H and M are whole numbers, and S is real. idamnjanovic@60: % idamnjanovic@60: % Example: Estimate the remaining time of a loop idamnjanovic@60: % idamnjanovic@60: % n = 10; tic; idamnjanovic@60: % for i = 1:n idamnjanovic@60: % pause(1); idamnjanovic@60: % [h,m,s] = secs2hms( (n-i)*toc/i ); idamnjanovic@60: % printf('estimated remaining time: %02d:%02d:%05.2f',h,m,s); idamnjanovic@60: % end idamnjanovic@60: idamnjanovic@60: idamnjanovic@60: % Ron Rubinstein idamnjanovic@60: % Computer Science Department idamnjanovic@60: % Technion, Haifa 32000 Israel idamnjanovic@60: % ronrubin@cs idamnjanovic@60: % idamnjanovic@60: % April 2008 idamnjanovic@60: idamnjanovic@60: idamnjanovic@60: s = t; idamnjanovic@60: h = fix(s/3600); idamnjanovic@60: s = rem(s,3600); idamnjanovic@60: m = fix(s/60); idamnjanovic@60: s = rem(s,60);