How Long Does it Take to Run Your Code?
25 Jan 2008 Daniel Sutoyo 2 comments 335 views
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.
2 Responses to “How Long Does it Take to Run Your Code?”
Leave a Reply
Include MATLAB code in your comment by doing the following:
<pre lang="MATLAB">
%insert code here
</pre>


i am trying for VRP ( vehicle routing ) simulation & optimisation in MATLAB.can u pls suggest experts in this areas , as i am stuck with my coding .VERY Urgent !! pls help
nice! didn’t know this.