MATLAB: Is it possible to control the size of the Command History contents using MATLAB 7.9 (R2009b)

buffercommandcontrolhistorylengthMATLABsize;

If I am using a MATLAB session for a long time and executing many commands in the command window, MATLAB does not seem to retain all the commands in the Command History. I am unable to find the commands which were executed at the beginning of the session.

Best Answer

In MATLAB 7.9 (R2009b) the Command History will only load up to 20,000 bytes from the history and will consecutively delete and resave the Command History. At any given time, you have either 20,000 bytes in the "history.m" file (available in the preference directory which is given by executing PREFDIR on the MATLAB command prompt) or the size of your last session. The file size is limited so the file does not grow infinitely and slow down MATLAB as MATLAB has to interact with the Command History.
As of MATLAB 7.12 (R2011a) the limit on the Command History File size was increased to 200,000 bytes.
Information about this limitation can be seen in the documentation by executing the following command from the MATLAB command line:
>> web([docroot '/techdoc/matlab_env/f0-17420.html#bs5yxo0-1'])
As a workaround, please use DIARY to maintain a record of all the commands entered in a particular session of MATLAB. For more information about DIARY, please refer to the MATLAB documentation using the following command:
>> doc diary