MATLAB: how to include running time on a graph?

336 Views Asked by At

I have a MATLAB/Octave program for which I used the tic and toc functions to measure the time elapsed for some calculations. e.g.:

tic();
for k=1:200
...
...
end
time=toc();

so now I have the value time.

how can I include this (anywhere and anyhow) automatically on a plot? as a legend? as a label? as a title?

1

There are 1 best solutions below

0
On BEST ANSWER

You can do this with the num2str-function. To display time in the title use for example:

title(['running time ' num2str(time) 's'])