Skip to content

mlxrun

io · scripts/io/mlxrun.m

: results = mlxrun (filename)
: results = mlxrun (filename, name, value, …)
: [results, workspace] = mlxrun (…)

Run the code cells of a MATLAB Live Script (.mlx) cell-by-cell and capture each cell’s textual output.

An .mlx file is an OPC ZIP archive whose code cells live in matlab/document.xml as paragraphs with style "code". Cells share one workspace in document order (like running the Live Script as a script). Text / title / heading paragraphs are skipped.

results is an N-by-1 cell array. Each entry is a scalar struct:

Index

1-based index among code cells (double).

Code

Character row vector with the cell source.

Output

Captured display output (character row vector), via evalc.

Status

"ok", "error", or "skipped" (when a prior cell failed and "StopOnError" is true).

ErrorId

Error identifier when Status is "error", otherwise ''.

ErrorMessage

Error message when Status is "error", otherwise ''.

With two outputs, workspace is a scalar struct of variables left in the shared cell workspace after the last executed cell (empty fields when nothing was assigned).

Name-value arguments:

"Cells" (default [] meaning all)

Vector of 1-based code-cell indices to run, in the order given.

"StopOnError" (default true)

When true, remaining selected cells after the first error are marked "skipped" and not executed.

Behaviour note: MATLAB R2026a has no public mlxrun. The closest internal API is matlab.internal.liveeditor.executeAndSave, which runs a whole Live Script and embeds outputs in the .mlx file but does not return per-cell capture. Nexus mlxrun is the clean-room cell-by-cell runner for that gap; error ids use the MATLAB:mlxrun:* family for consistency with sibling mlxread/mlxwrite APIs.