Have you ever been frustrated with Matlab when you forget that longwinded command sequence that took ages to get just right and would like to use again, but you didn’t write it down! The Matlab diary helps alleviate this problem. Basically it copies all typed input, and textual output in the command window into a file that you can refer back to at a later date.

To setup the diary such that you get 1 file for each day you use Matlab:

  1. Create a directory in which to store your diary files.
  2. Add the following line to your startup.m file:
  1.  
  2. diary(fullfile('pathname', date));

Note, one thing to be aware of is that if you accidentally display a large matrix, it will get added to your diary, so the files can get rather large. Here’s an example of what’s in my startup script:

  1.  
  2. % Add commonly used paths here
  3. Addpath('d:\name\Matlab')
  4.  
  5. % Add commonly used paths here
  6. Addpath('d:\myNameMatlab')
  7.  
  8. % Configure the diary to store today's Matlab session in
  9. diary(fullfile('d:\myNameMatlabDiaries', date))
  10.  
  11. % This helps alleviate some Matlab bugs to do with plotting coloured surfaces
  12. opengl neverselect;
  13.  
  14. % Change to my current working project directory
  15. cd 'pathNameHere';