Write to a Diary File
To keep an activity log of your MATLAB® session, use the
diary function. When enabled,
diary logs entered
commands, keyboard input, and text output from the Command Window to a UTF-8 encoded
text file on your system.
For example, if you have the array
A = [ 1 2 3 4; 5 6 7 8 ] in your
workspace, you can use the
diary function to save
A and its contents to a text file.
Enable logging using the
diaryfunction. Optionally, you can name the log file
diarycreates. For example, enable logging and specify the log filename as
diarycreates the file
my_data.outand starts recording all entered commands, keyboard input, and text output from the Command Window.
Display the contents of the array you want to save, for example,
A. You also can display a cell array or other MATLAB class.
A = 1 2 3 4 5 6 7 8
Display the contents of
A A = 1 2 3 4 5 6 7 8 diary off
my_data.outin a text editor and remove extraneous text, if desired.