-
Notifications
You must be signed in to change notification settings - Fork 7
/
my_toc.m
36 lines (32 loc) · 803 Bytes
/
my_toc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [t] = my_toc(ts, print, use_min)
%MY_TOC Prints a formatted toc from a tic context in a similar format
% like the other messages we have. Also supports displaying only in seconds
% minutes & seconds.
%
% Author Andreas Grammenos (ag926@cl.cam.ac.uk)
%
% Last touched date 06/06/2018
%
% License: GPLv3
%
% check if we print
if nargin < 2
print = 1;
end
% setup the defaults
if nargin < 3
use_min = 1;
end
% grab the time from the `ts` context
t = toc(ts);
% check if we enabled printing
if print == 1
% check if we use only seconds or minutes and seconds.
if use_min == 1
fprintf(" -- Elapsed time %d minutes %f seconds\n", ...
floor(t/60), rem(t, 60));
else
fprintf(" -- Elapsed time %d seconds..\n", t);
end
end
end