tic, toc

Purpose

Stopwatch timer.

Synopsis

tic
any statements 
toc
t = toc

Description

tic starts a stopwatch timer.

toc, by itself, prints the elapsed time since tic was used.

t = toc returns the elapsed time in t.

Examples

This example measures how the time required to solve a linear system varies with the order of a matrix.

for n = 1:100
    A = rand(n,n);
    b = rand(n,1);
    tic
    x = A\b;
    t(n) = toc;
end
plot(t)

See Also

clock, cputime, etime

(c) Copyright 1994 by The MathWorks, Inc.