Main Content

Write to a Diary File

To keep an activity log of your MATLAB®session, use thediaryfunction.diarycreates a verbatim copy of your MATLAB session in a disk file (excluding graphics).

For example, if you have the arrayAin your workspace,

A = [ 1 2 3 4; 5 6 7 8 ];

execute these commands at the MATLAB prompt to export this array usingdiary:

  1. Turn on thediaryfunction. Optionally, you can name the output filediarycreates:

    diary my_data.out
  2. Display the contents of the array you want to export. This example displays the arrayA. You could also display a cell array or other MATLAB class:

    A = 1 2 3 4 5 6 7 8
  3. Turn off thediaryfunction:

    日记了

    diarycreates the filemy_data.outand records all the commands executed in the MATLAB session until you turn it off:

    A = 1 2 3 4 5 6 7 8 diary off
  4. Open thediaryfilemy_data.outin a text editor and remove the extraneous text, if desired.