MATLAB: Does the long script run 50-100 times slower in MATLAB 6.5 (R13) than in MATLAB 6.1 (R12.1)

accelfilelinelineslongm-fileMATLABperformancer12.1r12p1r13runscriptslowslowerspeed

Why does my long script run 50-100 times slower in MATLAB 6.5 (R13) than in MATLAB 6.1 (R12.1)?
If I time my variable declaration script in MATLAB 6.5 (R13) using TIC/TOC, it runs MUCH slower than it ran in MATLAB 6.1 (R12.1).

Best Answer

This bug has been fixed for Release 14 (R14). For previous releases, please read below for any possible workarounds:
This is a bug in MATLAB 6.5 (R13) that has been forwarded to our development staff for investigation.
There are three potential workarounds:
1. Disable acceleration before executing the script and restore it after. The command to disable acceleration is:
feature accel off
and the command to enable it is:
feature accel on
2. This problem occurs most frequently with extremely long files (on the order of 10,000 lines.) If possible, break the script or function into several files or functions.
3. Run your script once, accepting the performance penalty, and save the variables created to a MAT-file. You can then load this MAT-file instead of executing the script.