diary — Log command-window text to a file.

diary records command-window stdout and stderr text to an append-only log file. It supports MATLAB function syntax and command syntax for enabling, disabling, toggling, and selecting the diary file.

Syntax

diary
diary(filename)
diary off
diary on

Inputs

NameTypeRequiredDefaultDescription
filenameOrStateStringScalarYesLog filename, `on`, or `off`.

Errors

IdentifierWhenMessage
More than one input argument is passed to diary.diary: expected zero or one input argument
The diary filename/state argument is not a string scalar or character row.diary: expected filename, 'on', or 'off'
The selected diary file cannot be opened for append through the active filesystem provider.diary: failed to open diary file
RunMat:diary:TooManyOutputsOne or more output arguments are requested from diary.diary: expected no output arguments

How diary works

  • diary with no input toggles logging on or off using the current diary file. The default file is diary.
  • diary filename and diary('filename') select a file and enable logging. Existing files are appended to rather than replaced.
  • diary on enables logging to the current file, and diary off disables logging.
  • The filename/state argument must be a string scalar, string scalar array, or character row. Empty text and nonscalar text values are rejected.
  • Diary writes go through the active RunMat filesystem provider, so sandboxed and virtual filesystem hosts receive the same file operations as normal file I/O builtins.
  • Command-window text captured by evalc is not written to the diary while the capture scope is active.
  • diary is a side-effecting sink and does not return output arguments. Requesting an output raises RunMat:diary:TooManyOutputs.

Does RunMat run diary on the GPU?

diary is a host-side logging builtin. It writes command-window text through the filesystem provider and is excluded from GPU execution and fusion planning.

Examples

Log command-window output to a file

diary runmat_session.log
A = magic(3);
disp(A)
diary off

Use function syntax to select a diary file

diary('experiment.log')
disp('started')
diary off

Toggle the current diary state

diary
disp('this line is logged')
diary

Using diary with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how diary changes the result.

Run a small diary example, explain the result, then change one input and compare the output.

FAQ

Does diary overwrite an existing file?

No. RunMat opens the selected diary file in append mode, matching MATLAB diary behavior.

Does diary log text captured by evalc?

No. Text captured by evalc is diverted into the returned string and is not written to the normal command stream or diary log.

Does diary log workspace variables or figure state?

No. It logs command-window text only. It does not change variables, figures, or execution state beyond the diary on/off state and selected filename.

Can diary return an output value?

No. Like MATLAB, diary is controlled for side effects. Assigning its result raises RunMat:diary:TooManyOutputs.

Can diary write to host-specific filesystems?

Yes. It uses the active RunMat filesystem provider, so desktop, sandboxed, and embedded hosts control where the log is created.

Does GPU residency matter for diary?

No. diary is a host-side file sink and does not create GPU kernels, participate in fusion, or preserve GPU residency.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how diary is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.