Read elapsed time from stopwatch
toc reads the elapsed time since the stopwatch timer started
by the call to the tic function. MATLAB® reads the internal time at the execution of the toc
function and displays the elapsed time since the most recent call to the
tic function without an output. The elapsed time is expressed
in seconds.
toc( displays the elapsed time
since the call to the timerVal)tic function corresponding to
timerVal.
elapsedTime = toc returns the elapsed time since the most
recent call to the tic function.
Consecutive calls to the toc function with no input
return the elapsed time since the most recent call to tic.
This property enables you to take multiple measurements from a single point in
time.
Consecutive calls to the toc function with the same
timerVal input return the elapsed time since the
tic function call that corresponds to
timerVal.
Sometimes programs run too fast for tic and
toc to provide useful data. If your code is faster than
1/10 second, consider measuring it running in a loop, and then average to find
the time for a single run. For more information, see Measure the Performance of Your Code.
The following actions result in unexpected output:
tic and toc to time
timeittic and toc within a
function timed by timeit