

function hms=sec2hms(sec)
hms=[];
if sec>(60*60*24)
 day=floor(sec/(60*60*24));
 sec=rem(sec,(60*60*24));
 hms=[num2str(day) 'day '];
else
 day=[];
end
if sec>(60*60)
 hour=floor(sec/(60*60));
 sec=rem(sec,(60*60));
 hms=[hms  num2str(hour) ':'];
else
 hour=[];
end
if sec>(60)
 min=floor(sec/(60));
 sec=rem(sec,(60));
 hms=[hms num2str(min) ':'];
else
 min=[];
end
hms=[hms num2str(sec)];
 