Create, edit, and run plain-text MATLAB live scripts (.m files) with rich text formatting, LaTeX equations, section breaks, and inline figures. Use when generating tutorials, analysis notebooks, reports, documentation, or educational content, when modifying existing live scripts, or when converting existing binary .mlx files to .m for version control. Requires R2025a+.
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-create-live-script
Plain-text .m files that render as rich documents in the MATLAB Live Editor. Version-control friendly — never use binary .mlx.
.m, not binary .mlx).mlx file to plain-text .m.mlxTo convert a binary .mlx file to a plain-text .m live script, run the following at the MATLAB Command Window. The recipe is not part of the resulting .m file:
editor = matlab.desktop.editor.openDocument(mlxPath, Visible=0);
editor.saveAs(newMPath); % use .m extension
editor.closeNoPrompt;
%[text] — NOT bare %%[text] line — do not hard-wrap; let the Live Editor handle line width%[text] lines — they render as unwanted blank space%% on its own line, then %[text] ## Title on next line%[appendix]figure command — implicit figure creation onlyclose all or clearmfilename — does not work as intended in live scripts. Hardcode filenames or use pwd.*, _, [, ], , \. Also escape . after a digit and #` at line start.$ inline form only: $ a = \\pi r^2 $ (no $$ ... $$). For a centered/display equation, wrap the line: %[text]{"align":"center"} $ X(k) = \\sum\_{n=0}^{N-1} x(n) e^{-j2\\pi kn/N} $\\sin, \\frac, \\pi) and markdown characters take single (\_, \*). Use a tool that takes literal text (Edit, Write, fwrite) — don't use Bash heredocs; they collapse \\ to \ even when quoted, which corrupts LaTeX equations.\fprintf — drop the semicolon or use disp(). Output appears inline below the code that produced it, not in the Command Window.Every live script must end with:
%[appendix]{"version":"1.0"}
%---
%[metadata:view]
% data: {"layout":"inline"}
%---
When reading a live script file, ignore everything below the %[appendix] marker. The appendix contains embedded images and metadata that consume tokens without adding useful information. All code and text content appears before it.
| Syntax | Renders as |
|--------|-----------|
| %% | Section break |
| %[text] # Title | H1 heading |
| %[text] ## Section | H2 heading |
| %[text] bold | Bold |
| %[text] *italic* | *Italic* |
| %[text] code | Monospace |
| %[text] <u>text</u> | Underlined text |
| %[text] $ a = \\pi r^2 $ | Inline equation |
| %[text]{"align":"center"} $ ... $ | Centered/display equation |
| %[text] - item | Bullet |
| %[text] - last \ | Last bullet |
| %[text] 1. item | Numbered list |
| %[text] 2. last \ | Last numbered item |
| %text] [text | External hyperlink |
| %text] [text | Internal link to an anchor |
| %[text] %[text:anchor:id] ... | Anchor (link target) |
| %[text:tableOfContents]{"heading":"..."} | Table of Contents |
IDs (anchors, and any other id-bearing element): letters, digits, and underscores only. No hyphens — my-section won't bind; use my_section. For anchors, place the marker immediately after %[text] at the start of the line.
%[text:table]
%[text] | Method | Result |
%[text] | --- | --- |
%[text] | Trapezoidal | 1.9998 |
%[text:table]
%[text] # Sinusoidal Signals
%[text] Examples of sinusoidal signals in MATLAB.
%[text:tableOfContents]{"heading":"Contents"}
%[text] - sine waves
%[text] - cosine waves \
x = linspace(0,8*pi);
%%
%[text] ## Sine Wave
plot(x,sin(x))
title('Sine Wave')
xlabel('x (radians)')
ylabel('sin(x)')
grid on
%%
%[text] ## Cosine Wave
plot(x,cos(x))
title('Cosine Wave')
xlabel('x (radians)')
ylabel('cos(x)')
grid on
%%
%[text] ## Summary
%[text] The sine and cosine functions are $ \\pi/2 $ radians out of phase.
%[appendix]{"version":"1.0"}
%---
%[metadata:view]
% data: {"layout":"inline"}
%---
%[text] ## Theory
%[text] The discrete Fourier transform is defined as:
%[text]{"align":"center"} $ X(k) = \\sum\_{n=0}^{N-1} x(n) e^{-j2\\pi kn/N} $
%[text] where $ x(n) $ are the time-domain samples and $ k $ indexes the frequency bins.
%%
%[text] ## Data Processing
%[text] Load and filter the data, then visualize the results.
data = load('measurements.mat');
filtered = lowpass(data, 0.5); % Apply lowpass filter
plot(filtered)
title('Filtered Data')
Use only when side-by-side comparison is important to the illustration:
%%
%[text] ## Comparison of Methods
tiledlayout(1,2)
nexttile
plot(method1)
title('Method 1')
nexttile
plot(method2)
title('Method 2')
%[text] for text, %% for sections, appendix at end. Use a tool that takes literal text (Edit, Write, fwrite). Don't use Bash heredocs (cat > file <<EOF); they collapse \\ to \ even when quoted, which corrupts LaTeX equations.evaluate_matlab_code to confirm it executes cleanly. Note the wall-clock time — Embed Outputs takes about the same.executeLiveScript("<absolute-path>.m") to save each section's outputs (plots, displayed values) inline next to the code that produced them.export("<absolute-path>.m", "<absolute-path>.html") to produce an HTML approximation of the rendered document. Read it back to confirm equations are typeset, figures appear inline, %[text] directives don't leak as literal text, etc. Delete the .html when done — it's a verification artifact, not a deliverable.The Write step is the load-bearing one — Write alone produces a valid live script the user can open and run. Validate, Embed Outputs, and Verify Rendering are progressive enhancements that require an attached MATLAB session. Without one, stop after Write. After Embed Outputs, the file is rewritten to disk by MATLAB — re-read before any further edits.
executeLiveScriptBundled in the scripts/ folder of this skill. Add to path before first use:
addpath(fullfile(skillRoot, "scripts")); % skillRoot = directory containing this SKILL.md
Calling executeLiveScript(filePath) returns nothing on success. Runtime errors inside the script do not raise exceptions — the script writes them into the appendix as "dataType":"error" blocks; grep the saved .m to find them.
Run Validate before Embed Outputs. If a cell errors during Embed Outputs, that cell becomes an error block and outputs in cells *after* it are stripped from the file. Run through evaluate_matlab_code first.
If Embed Outputs errors with "Nested Live Editor execution" or hangs past the Validate time: retry once with the MATLAB desktop visible. If that also fails, the on-disk file from Write is still valid — skip Embed Outputs and let the user run the script themselves.
Before finishing a live script, verify:
%% alone on its own line, followed by %[text] ##%[text] lines (except one blank line directly before %[appendix])%[text] line (no hard-wrapping)\\sin, \\frac, \\pifigure commandsclose all or clear at startmfilenameMinor features planned for a future revision:
----
Copyright 2026 The MathWorks, Inc.
----
Integration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io functionality into workflows. Applicable for protocol discovery, collaborative protocol development, experiment tracking, lab protocol management, and scientific documentation.
Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances
Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.
Build and distribute Expo development clients locally or via TestFlight
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
Benchling R&D platform integration. Access registry (DNA, proteins), inventory, ELN entries, workflows via API, build Benchling Apps, query Data Warehouse, for lab data management automation.
Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.
Take matlab/matlab-create-live-script from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.