| Contents | Index |
toc
toc(ticID)
elapsedTime = toc
elapsedTime = toc(ticID)
toc stops a stopwatch timer started by the tic function, and displays the time elapsed in seconds.
toc(ticID) displays the time elapsed since the tic command corresponding to ticID.
elapsedTime = toc stores the elapsed time in a variable.
elapsedTime = toc(ticID) stores in a variable the time elapsed since the tic command corresponding to ticID.
Consecutive toc commands return the increasing time that has elapsed since the most recent tic. Therefore, you can take multiple measurements from a single point in time.
The toc function displays the time elapsed unless you specify an output argument.
ticID |
Identifier generated by a previous call to tic with an output argument. |
elapsedTime |
Scalar double representing the time elapsed between tic and toc commands, in seconds. |
Measure how the time required to solve a linear system varies with the order of a matrix:
t = zeros(1,100);
for n = 1:100
A = rand(n,n);
b = rand(n,1);
tic
x = A\b;
t(n) = toc;
end
plot(t)Measure the minimum and average time to compute a summation of Bessel functions:
REPS = 1000; minTime = Inf; nsum = 10;
tic;
for i=1:REPS
tStart = tic; total = 0;
for j=1:nsum,
total = total + besselj(j,REPS);
end
tElapsed = toc(tStart);
minTime = min(tElapsed, minTime);
end
averageTime = toc/REPS;clock | cputime | etime | profile | tic

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |