print command window readout to text file in matlab

You can redirect the command window to a text file using the diary command.

Here's an example:

main.m
% start logging to a file
diary mylog.txt

% print some text to the command window
disp('Hello world')

% stop logging to the file
diary off
141 chars
9 lines

After running this code, the file mylog.txt will be created in the current directory, and it will contain the text "Hello world".

Note that all output to the command window will be logged to the file until diary off is called, so make sure to turn off logging when you're done.

related categories

gistlibby LogSnag