Skip to Main Content Skip to Search
Product Documentation

tic - Start clock to measure performance

Syntax

tic
ticID = tic

Description

tic starts a stopwatch timer. Stop the timer with the toc function.

ticID = tic stores an identifier for the tic command, so that you can nest timing operations.

Tips

Output Arguments

ticID

Value to use as an input argument for a subsequent call to toc. The value has no independent meaning.

Examples

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;

See Also

clock | cputime | etime | profile | toc

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS