Save Command Window text to file
diary function creates a log of keyboard
input and the resulting text output, with some exceptions (see Tips for details). The output of
an ASCII file, suitable for searching in, printing, inclusion in most
reports and other documents. If you do not specify
the MATLAB® software creates a file named
the current folder.
on and off. To see the status of
get(0,'Diary'). MATLAB returns
a copy of all subsequent keyboard input and the resulting output (except
it does not include graphics) to the named file, where
the full pathname or
filename is in the current MATLAB folder.
If the file already exists, output is appended to the end of the file.
You cannot use a
To see the name of the
diary file, use
diary off suspends
diary on resumes
diary mode using the current filename, or the default filename
none has yet been specified.
diary filename is the unquoted
form of the syntax.
Because the output of
diary is plain text,
the file does not exactly mirror input and output from the Command
Output does not include graphics (figure windows).
Syntax highlighting and font preferences are not preserved.
Hidden components of Command Window output such as hyperlink
information generated with
matlab: are shown in
plain text. For example, if you enter the following statement
str = sprintf('%s%s', ... '<a href="matlab:magic(4)">', ... 'Generate magic square</a>'); disp(str)
However, the diary file, when viewed in a text editor, shows
str = sprintf('%s%s', ... '<a href="matlab:magic(4)">', ... 'Generate magic square</a>'); disp(str) <a href="matlab:magic(4)">Generate magic square</a>
If you view the output of diary in the Command Window, the Command
Window interprets the
<a href ...> statement
and displays it as a hyperlink.
Viewing the output of
a console window might produce different results compared to viewing
in the desktop Command Window. One example
is using the
\r option for the
fprintf function; using the
might alleviate that problem.