blob: f99c53d970623e40980bedf2faeeb947d274555b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
function num_as_str = get_time_as_string(millis)
%GET_TIME_AS_STRING Number of milliseconds, formatted mm:ss.s and rounded
% Detailed explanation goes here
minutes = fix(millis / (1000*60));
seconds = mod(millis, 1000*60);
rest = round(mod(seconds, 1000), -2) / 100;
if rest == 10
seconds = seconds + 1*1000;
rest = 0;
end
minutes_str = num2str(minutes);
seconds_str = sprintf('%02d', fix(seconds / 1000));
rest_str = num2str(rest);
num_as_str = strjoin({minutes_str, ':', seconds_str, '.', rest_str}, '');
end
|