Matlab comes built in with a profiler. It is much akin to the profiler in valgrind, only that in true matlab fashion it generates a html report of the profiler.
Profiling can be used to look at specfic runs of functions and the call tree, it generates statistics like the number of times a function was called and how much time a function takes to execute.
This kind of information can provide key insight into blockages, especially on the IO front. For example, in C++ it is better to use "\n" than endl to mark end of lines.endl flushes the buffer and adds consdierable overhead. In matlab, you don't figure out why some functions are slow, you can use profiling to pinpoint the exact line causing the bottleneck. This can be crucial especially if you deal with big datasets and/or heavy computation.
So, if you now have code which you want to profile and say save the stats and measure, simply run the following commands and it will be done.