Write to a Diary File
To keep an activity log of your MATLAB® session, use the diary
function.
diary
creates a verbatim copy of your MATLAB session in a disk file (excluding graphics).
For example, if you have the array A
in your
workspace,
A = [ 1 2 3 4; 5 6 7 8 ];
execute these commands at the MATLAB prompt to export this
array using diary
:
Turn on the
diary
function. Optionally, you can name the output filediary
creates:diary my_data.out
Display the contents of the array you want to export. This example displays the array
A
. You could also display a cell array or other MATLAB class:A = 1 2 3 4 5 6 7 8
Turn off the
diary
function:diary off
diary
creates the filemy_data.out
and 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
Open the
diary
filemy_data.out
in a text editor and remove the extraneous text, if desired.