| MATLAB Function Reference | ![]() |
| tic |
| any statements |
| toc |
| t = toc |
toc prints the elapsed time since tic was used.
t = toc returns the elapsed time in t.
The tic and toc functions work together to measure elapsed time. tic saves the current time that toc uses later to measure the elapsed time. The sequence of commands
tic operations toc
measures the amount of time the MATLAB® software takes to complete one or more operations, and displays the time in seconds.
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)clock, cputime, etime, profile
![]() | throwAsCaller (MException) | timer | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |