MATLAB: Does the long simulation slow down over time

ramsimulationstictimetoc

I am running long simulations involving a double for-loop with each approx. 20 intervals, and each internal process taking anywhere between an hour and a day. When initiating this simulation it will start off at a rapid pace, and will slow down at a rate which appears to be correlated to the decreasing availability of RAM on the computer. This, however, puzzles me as I have set it up so that nothing, apart from a handful of matrices, is stored in between the individual processes and all matrices are assigned before use so nothing grows without being pre-assigned.
Does anyone know of any tricks I can use? Is this just to be expected for long matlab runs in general? using tic/toc or profile only emphasizes that the whole thing slows down.
Thanks in advance

Best Answer

Jakob, do any of your operations display an image in an axes? If so, all of those images "stack up" in the axes control and sap memory. They're all in there even though you only see the top one displayed. Be sure to use "cla" before loading a new image in, and it will be faster, otherwise it will get slower and slower as more and more images get displayed.