mlxrun
- :
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:
Index1-based index among code cells (double).
CodeCharacter row vector with the cell source.
OutputCaptured display output (character row vector), via
evalc.Status"ok","error", or"skipped"(when a prior cell failed and"StopOnError"is true).ErrorIdError identifier when
Statusis"error", otherwise''.ErrorMessageError message when
Statusis"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"(defaulttrue)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 ismatlab.internal.liveeditor.executeAndSave, which runs a whole Live Script and embeds outputs in the .mlx file but does not return per-cell capture. Nexusmlxrunis the clean-room cell-by-cell runner for that gap; error ids use theMATLAB:mlxrun:*family for consistency with siblingmlxread/mlxwriteAPIs.