MATLAB: Program runtime question

runtime

Hi,
I have a program that (for what I've done so far) takes a long time to run (~4s per loop). In the final version of the code I will be performing hundreds of loops. Would it be quicker if I assigned parts of the code as functions, or would this actually increase the run time?
Thanks
Richard

Best Answer

It is difficult to predict exactly how MATLAB will optimize code. Especially before 2010b, the details how how the code was written in the file could make a substantial difference. This is one of those "You'd have to try it and see" matters.
Have you used the profiler to track down the portion of your code that is taking a lot of time?