Matlab Logo Wouldn’t it be nice if you have a stopwatch to time how long your code runs for? If you ever need more than just an eyeball estimate with a regular clock, take advantage of the matlab’s stopwatch: tic and toc.

Simply put tic before the first line of your code, and end the m-file with toc.

tic     % start time
%---operations---
x = 0;
for i = 1:10000
x = x+1
end
%----------------
toc    % stop time

You will get an elapsed time result

Elapsed time is 0.000040 seconds.