What is your favourite MATLAB/Octave programming trick?

Matt picture Matt · Sep 25, 2008 · Viewed 31.7k times · Source

I think everyone would agree that the MATLAB language is not pretty, or particularly consistent. But nevermind! We still have to use it to get things done.

What are your favourite tricks for making things easier? Let's have one per answer so people can vote them up if they agree. Also, try to illustrate your answer with an example.

Answer

Jason Sundram picture Jason Sundram · Oct 14, 2008

Using the built-in profiler to see where the hot parts of my code are:

profile on
% some lines of code
profile off
profile viewer

or just using the built in tic and toc to get quick timings:

tic;
% some lines of code
toc;