diary

Records the text of a session to a file.

Category: Language Fundamentals > Entering Commands

Syntax

diary

Switches logging on or off.

diary on / diary off

Turns the log on or off.

diary(filename)

Starts logging to filename.

Description

While the diary is on, what appears in the command window is also appended to the file. The commands themselves and their printed output are captured, so the file is a transcript. diary off stops recording but keeps the file.

Input arguments

filename
Name of the log file. The default is diary in the current folder.

Example

Log a short session

diary('session.txt')
disp('logged line')
diary off
Output
logged line

See also

disp fprintf more