MATLAB and GNU Octave
Use this skill to design or review numerical code, migrate MATLAB releases,
prepare reproducible projects, and plan trusted execution. MATLAB and GNU
Octave are distinct products: compatibility is partial, not a license or
behavior guarantee.
Product and license gate
- MATLAB R2026a is proprietary. Do not assume MATLAB, MATLAB Online, a
named toolbox, MATLAB Test, MATLAB Compiler, MATLAB Coder, Parallel Computing
Toolbox, or an add-on is installed, licensed, or available to the user.
- MATLAB Runtime is not MATLAB. It runs compatible applications produced
with MATLAB Compiler; it cannot run arbitrary source or host MATLAB Engine
for Python. Building artifacts needs the applicable licensed compiler and
every product used by the source.
- GNU Octave 11.3.0 is free software under GPLv3+. Octave packages are not
MATLAB toolboxes. Similar names do not imply API, numerical, graphics, or
licensing equivalence.
- Ask which runtime, release, platform, installed products, and license context
the user actually has. Treat availability as
unknown until confirmed.
See Octave compatibility and
execution/product boundaries.
Nonnegotiable safety boundary
Never run an untrusted .m, .mlx, MEX binary, MAT file, project startup or
shutdown action, package installer, or generated artifact. Static review does
not prove safety.
Treat these as execution or code-loading surfaces:
eval, evalin, assignin, text-derived feval, str2func, callbacks,
timers, app callbacks, and dynamically modified paths;
system, unix, dos, shell escape !, Java, .NET, Python (py.*,
pyrun, pyrunfile), MEX, and native libraries;
mex, codegen, MATLAB Compiler, build tasks, package/project startup, and
generated code;
load, object deserialization (loadobj, custom serialization), function
handles, Java/System objects, and class code reachable from MAT files.
.mlx is an opaque archive for this toolkit and MEX is native executable code.
Do not use Python pickle for exchange. Inspect first, isolate when appropriate,
obtain explicit approval, then invoke a user-confirmed executable and license.
Bundled scripts are static or dry-run tools: none launches MATLAB, Octave,
Python Engine, a compiler, or a subprocess.
Default workflow
- Clarify target. Record MATLAB release or Octave version, OS/architecture,
base product versus required toolboxes/packages, expected inputs/outputs,
numerical tolerances, and whether execution is authorized.
- Inventory statically. Scan
.m files, opaque artifacts, project paths,
required products, and MAT headers before any runtime loads them.
- Choose code form. Prefer functions with an
arguments block for
automation. Use scripts only for controlled orchestration and live scripts
for reviewed interactive narratives.
- Make semantics explicit. Record shapes, classes, units, missing-value
rules, indexing, implicit expansion, RNG algorithm/seed, tolerances, and
output formats.
- Test without hidden state. Keep fixtures synthetic, paths project-local,
graphics deterministic, and tests independent of base-workspace residue.
- Plan execution. Generate an argv plan, review startup/path effects and
licenses, and launch only after explicit approval outside these helpers.
- Capture provenance. Hash named inputs/code and record release, products,
RNG policy, tolerances, and command plan without dumping the environment.
Language and data checklist
Scripts, functions, and live scripts
- Scripts share the caller/base workspace and leave variables behind.
Functions have local workspaces and explicit inputs/outputs.
- Live scripts (
.mlx) mix code and rich output but are not plain-text
review artifacts. Export reviewed code to .m for static inspection.
- Avoid
clear all, broad addpath(genpath(...)), dependence on pwd, global
variables, and silent name shadowing. Use project roots and fullfile.
- Validate sizes, classes, and values in
arguments blocks. Remember that
type declarations can convert inputs; validators check without converting.
- A main function file should match the main function name. Local functions
are private to the file; since R2024a they can appear anywhere in a script
outside conditional contexts.
function y = scaleSignal(x, options)
arguments
x (:,1) double {mustBeFinite}
options.Scale (1,1) double {mustBeFinite, mustBeNonzero} = 1
end
y = x .* options.Scale;
end
Read programming.
Arrays, indexing, and numerics
- MATLAB uses 1-based, column-major indexing.
A(i,j), A(k), A(:,j),
A{...}, and A.(name) have different semantics.
*, /, \, and ^ are matrix operations; dotted forms are
element-wise. Use A\b, not inv(A)*b.
- Since R2016b, compatible dimensions expand implicitly. Assert intended shape
before operations that could accidentally form an outer result.
- Preallocate when output size is known, but do not vectorize at the cost of
huge temporaries or unreadable code. Measure with
timeit or the profiler.
- Compare floating-point results with domain-chosen absolute and relative
tolerances, not blanket
== or a magic multiple of eps.
- Pin both random algorithm and seed. Use named
RandStream substreams for
independent parallel work; do not use time-based rng("shuffle") for a
reproducibility claim.
Read arrays and
mathematics.
Tables, timetables, and missing values
- A
table has named, equal-height variables that may have different types.
T(rows,vars) returns a table; T{rows,vars} extracts contents; T.Var
selects one variable.
- A
timetable additionally has row times. Sort, validate time zones and
uniqueness, then use retime/synchronize intentionally.
- Missing sentinels are type-specific:
NaN, NaT, <missing>,
<undefined>, and empty character vectors. Integer and logical arrays have
no standard missing sentinel.
- Define import options rather than relying on inference for production data.
Preserve units, time zones, variable names, encodings, and missing rules.
Read data import/export.
Graphics and export
Use explicit figure/axes handles and tiledlayout; label units; set limits,
color scales, font sizes, and colormaps deliberately. Prefer exportgraphics
over saveas for publication output. In R2026a it exports raster, PDF/EPS/EMF,
SVG, GIF, and interactive HTML; format capabilities differ. Specify
ContentType="vector" for suitable PDF/SVG-style output and Resolution for
raster output. Review accessibility and embedded-raster behavior.
Read graphics and export.
MAT files and exchange
- Version 7 is the normal
save default; matfile creates 7.3 by default.
Versions 4/6/7/7.3 differ in types, compression, and per-variable limits.
- Version 7.3 is HDF5-based, not an arbitrary HDF5 interchange contract.
Partial access and chunking can help large arrays.
- Never load an untrusted MAT file. Inventory headers/datasets first. Objects
can invoke class deserialization behavior; opaque/function/native content
requires escalation.
- Prefer CSV/JSON/Parquet/HDF5 with a documented schema for simple exchange.
Do not rename pickle payloads as MAT files and do not deserialize pickle.
Read data import/export.
Projects, analysis, and tests
- Use MATLAB Projects for controlled paths, startup/shutdown tasks,
dependencies, source control, and reproducible entry points. Review project
actions before opening an untrusted project.
matlab.codetools.requiredFilesAndProducts and Dependency Analyzer are
static approximations; dynamic dispatch can cause misses or false positives.
A required-product report does not prove a license is available.
- Use Code Analyzer (
codeIssues; legacy text workflows can use checkcode)
and codeCompatibilityReport before migration.
- Base MATLAB includes script-, function-, and class-based
matlab.unittest workflows. Parallel runs require Parallel Computing
Toolbox. Dependency-based selection, richer quality dashboards, generated
tests, and advanced coverage/equivalence features can require MATLAB Test or
other products.
- R2026a
runtests automatically opens and later closes a project when target
tests belong to a project that is not already open. Account for startup and
shutdown actions before using this behavior.
Read programming and
execution/testing.
Python integration, pinned to R2026a
- R2026a supports 64-bit CPython 3.9-3.13 for MATLAB Interface to Python,
MATLAB Engine for Python, and MATLAB Compiler SDK for Python.
- The current R2026a PyPI package reviewed here is
matlabengine==26.1.12 (released 2026-05-08). It requires an installed
R2026a; MATLAB Runtime alone is insufficient. R2026a also ships a
preinstalled Engine distribution under one named matlabroot path.
- Package installation does not grant MATLAB or toolbox licenses. Configure
one named interpreter/executable; do not print the full environment,
PATH, PYTHONPATH, or credentials.
pyenv controls MATLAB-to-Python interpreter selection. In-process Python
generally requires restarting MATLAB to switch; out-of-process Python can
be terminated and reconfigured.
- Starting Engine is an explicit execution action:
matlab.engine.start_matlab() starts a MATLAB process and can check out a
license. Never call it merely to probe availability.
- Verify conversion semantics for NumPy arrays, pandas DataFrames,
tables/timetables, strings/missing values, datetime/duration, dictionaries,
shape/order, and unsupported sparse/object/categorical cases.
Read Python integration.
Local helper CLIs
Every helper is network-free, bounded, symlink-rejecting, and nonexecuting.
Run from this skill directory with Python 3.11+. Bash is allowed only to invoke
these Python CLIs and validation commands; never use it to execute a generated
MATLAB/Octave argv plan or untrusted artifact.
| Helper |
Purpose |
scripts/plan_batch_command.py |
Produce reviewed MATLAB/Octave argv; never execute |
scripts/scan_m_code.py |
Scan .m text and flag opaque .mlx/MEX risks |
scripts/validate_project_manifest.py |
Validate paths and declared product/license status |
scripts/inventory_mat_file.py |
Header/metadata inventory; never call loadmat |
scripts/plan_python_compatibility.py |
Check R2026a CPython/Engine compatibility |
scripts/reproducibility_report.py |
Hash named local artifacts and emit a bounded report |
scripts/generate_function_scaffold.py |
Dry-run or create function and unit-test scaffolds |
python scripts/scan_m_code.py path/to/source --root path/to/project
python scripts/plan_batch_command.py matlab script path/to/main.m --root path/to/project
python scripts/validate_project_manifest.py project-manifest.json --root path/to/project
python scripts/inventory_mat_file.py data.mat --root path/to/project
python scripts/plan_python_compatibility.py --python-version 3.13
python scripts/reproducibility_report.py --root path/to/project --file src/analyze.m
python scripts/generate_function_scaffold.py analyzeSignal --root path/to/project
The scaffold generator defaults to dry-run; writing requires --write and
refuses collisions. SciPy and h5py are optional inventory backends; if
authorized, add exact reviewed versions to the caller's project lockfile.
They are not required for --help or header-only inventory, and this skill
does not perform package installation.
References
- Programming, workspaces, projects, analysis, tests
- Matrices, indexing, types, missingness, performance
- Numerical methods, tolerances, RNG, toolbox boundaries
- Graphics and
exportgraphics
- Import/export, tables/timetables, MAT semantics and safety
- MATLAB/Octave command-line execution and migration
- MATLAB and Python interoperability
- GNU Octave 11.3.0 compatibility differences
Bundled JSON assets are the project manifest,
reproducibility manifest, and
R2026a Python table. There is no
templates/ directory and no Markdown file is loaded from assets/;
local-link tests enforce this package contract.
Primary sources (verified 2026-07-23)
1---2name: matlab3description: Build, review, migrate, and safely plan MATLAB or GNU Octave numerical workflows, including arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.4license: MIT5---6
7# MATLAB and GNU Octave
8
9Use this skill to design or review numerical code, migrate MATLAB releases,
10prepare reproducible projects, and plan trusted execution. MATLAB and GNU
11Octave are distinct products: compatibility is partial, not a license or
12behavior guarantee.
13
14## Product and license gate
15
16- **MATLAB R2026a is proprietary.** Do not assume MATLAB, MATLAB Online, a
17 named toolbox, MATLAB Test, MATLAB Compiler, MATLAB Coder, Parallel Computing
18 Toolbox, or an add-on is installed, licensed, or available to the user.
19- **MATLAB Runtime is not MATLAB.** It runs compatible applications produced
20 with MATLAB Compiler; it cannot run arbitrary source or host MATLAB Engine
21 for Python. Building artifacts needs the applicable licensed compiler and
22 every product used by the source.
23- **GNU Octave 11.3.0 is free software under GPLv3+.** Octave packages are not
24 MATLAB toolboxes. Similar names do not imply API, numerical, graphics, or
25 licensing equivalence.
26- Ask which runtime, release, platform, installed products, and license context
27 the user actually has. Treat availability as `unknown` until confirmed.
28
29See [Octave compatibility](references/octave-compatibility.md) and
30[execution/product boundaries](references/executing-scripts.md).
31
32## Nonnegotiable safety boundary
33
34Never run an untrusted `.m`, `.mlx`, MEX binary, MAT file, project startup or
35shutdown action, package installer, or generated artifact. Static review does
36not prove safety.
37
38Treat these as execution or code-loading surfaces:
39
40- `eval`, `evalin`, `assignin`, text-derived `feval`, `str2func`, callbacks,
41 timers, app callbacks, and dynamically modified paths;
42- `system`, `unix`, `dos`, shell escape `!`, Java, .NET, Python (`py.*`,
43 `pyrun`, `pyrunfile`), MEX, and native libraries;
44- `mex`, `codegen`, MATLAB Compiler, build tasks, package/project startup, and
45 generated code;
46- `load`, object deserialization (`loadobj`, custom serialization), function
47 handles, Java/System objects, and class code reachable from MAT files.
48
49`.mlx` is an opaque archive for this toolkit and MEX is native executable code.
50Do not use Python pickle for exchange. Inspect first, isolate when appropriate,
51obtain explicit approval, then invoke a user-confirmed executable and license.
52Bundled scripts are static or dry-run tools: none launches MATLAB, Octave,
53Python Engine, a compiler, or a subprocess.
54
55## Default workflow
56
571. **Clarify target.** Record MATLAB release or Octave version, OS/architecture,
58 base product versus required toolboxes/packages, expected inputs/outputs,
59 numerical tolerances, and whether execution is authorized.
602. **Inventory statically.** Scan `.m` files, opaque artifacts, project paths,
61 required products, and MAT headers before any runtime loads them.
623. **Choose code form.** Prefer functions with an `arguments` block for
63 automation. Use scripts only for controlled orchestration and live scripts
64 for reviewed interactive narratives.
654. **Make semantics explicit.** Record shapes, classes, units, missing-value
66 rules, indexing, implicit expansion, RNG algorithm/seed, tolerances, and
67 output formats.
685. **Test without hidden state.** Keep fixtures synthetic, paths project-local,
69 graphics deterministic, and tests independent of base-workspace residue.
706. **Plan execution.** Generate an argv plan, review startup/path effects and
71 licenses, and launch only after explicit approval outside these helpers.
727. **Capture provenance.** Hash named inputs/code and record release, products,
73 RNG policy, tolerances, and command plan without dumping the environment.
74
75## Language and data checklist
76
77### Scripts, functions, and live scripts
78
79- Scripts share the caller/base workspace and leave variables behind.
80 Functions have local workspaces and explicit inputs/outputs.
81- Live scripts (`.mlx`) mix code and rich output but are not plain-text
82 review artifacts. Export reviewed code to `.m` for static inspection.
83- Avoid `clear all`, broad `addpath(genpath(...))`, dependence on `pwd`, global
84 variables, and silent name shadowing. Use project roots and `fullfile`.
85- Validate sizes, classes, and values in `arguments` blocks. Remember that
86 type declarations can convert inputs; validators check without converting.
87- A main function file should match the main function name. Local functions
88 are private to the file; since R2024a they can appear anywhere in a script
89 outside conditional contexts.
90
91```matlab
92function y = scaleSignal(x, options)
93arguments
94 x (:,1) double {mustBeFinite}
95 options.Scale (1,1) double {mustBeFinite, mustBeNonzero} = 1
96end
97y = x .* options.Scale;
98end
99```
100
101Read [programming](references/programming.md).
102
103### Arrays, indexing, and numerics
104
105- MATLAB uses 1-based, column-major indexing. `A(i,j)`, `A(k)`, `A(:,j)`,
106 `A{...}`, and `A.(name)` have different semantics.
107- `*`, `/`, `\`, and `^` are matrix operations; dotted forms are
108 element-wise. Use `A\b`, not `inv(A)*b`.
109- Since R2016b, compatible dimensions expand implicitly. Assert intended shape
110 before operations that could accidentally form an outer result.
111- Preallocate when output size is known, but do not vectorize at the cost of
112 huge temporaries or unreadable code. Measure with `timeit` or the profiler.
113- Compare floating-point results with domain-chosen absolute and relative
114 tolerances, not blanket `==` or a magic multiple of `eps`.
115- Pin both random algorithm and seed. Use named `RandStream` substreams for
116 independent parallel work; do not use time-based `rng("shuffle")` for a
117 reproducibility claim.
118
119Read [arrays](references/matrices-arrays.md) and
120[mathematics](references/mathematics.md).
121
122### Tables, timetables, and missing values
123
124- A `table` has named, equal-height variables that may have different types.
125 `T(rows,vars)` returns a table; `T{rows,vars}` extracts contents; `T.Var`
126 selects one variable.
127- A `timetable` additionally has row times. Sort, validate time zones and
128 uniqueness, then use `retime`/`synchronize` intentionally.
129- Missing sentinels are type-specific: `NaN`, `NaT`, `<missing>`,
130 `<undefined>`, and empty character vectors. Integer and logical arrays have
131 no standard missing sentinel.
132- Define import options rather than relying on inference for production data.
133 Preserve units, time zones, variable names, encodings, and missing rules.
134
135Read [data import/export](references/data-import-export.md).
136
137## Graphics and export
138
139Use explicit figure/axes handles and `tiledlayout`; label units; set limits,
140color scales, font sizes, and colormaps deliberately. Prefer `exportgraphics`
141over `saveas` for publication output. In R2026a it exports raster, PDF/EPS/EMF,
142SVG, GIF, and interactive HTML; format capabilities differ. Specify
143`ContentType="vector"` for suitable PDF/SVG-style output and `Resolution` for
144raster output. Review accessibility and embedded-raster behavior.
145
146Read [graphics and export](references/graphics-visualization.md).
147
148## MAT files and exchange
149
150- Version 7 is the normal `save` default; `matfile` creates 7.3 by default.
151 Versions 4/6/7/7.3 differ in types, compression, and per-variable limits.
152- Version 7.3 is HDF5-based, not an arbitrary HDF5 interchange contract.
153 Partial access and chunking can help large arrays.
154- Never load an untrusted MAT file. Inventory headers/datasets first. Objects
155 can invoke class deserialization behavior; opaque/function/native content
156 requires escalation.
157- Prefer CSV/JSON/Parquet/HDF5 with a documented schema for simple exchange.
158 Do not rename pickle payloads as MAT files and do not deserialize pickle.
159
160Read [data import/export](references/data-import-export.md).
161
162## Projects, analysis, and tests
163
164- Use MATLAB Projects for controlled paths, startup/shutdown tasks,
165 dependencies, source control, and reproducible entry points. Review project
166 actions before opening an untrusted project.
167- `matlab.codetools.requiredFilesAndProducts` and Dependency Analyzer are
168 static approximations; dynamic dispatch can cause misses or false positives.
169 A required-product report does not prove a license is available.
170- Use Code Analyzer (`codeIssues`; legacy text workflows can use `checkcode`)
171 and `codeCompatibilityReport` before migration.
172- Base MATLAB includes script-, function-, and class-based
173 `matlab.unittest` workflows. Parallel runs require Parallel Computing
174 Toolbox. Dependency-based selection, richer quality dashboards, generated
175 tests, and advanced coverage/equivalence features can require MATLAB Test or
176 other products.
177- R2026a `runtests` automatically opens and later closes a project when target
178 tests belong to a project that is not already open. Account for startup and
179 shutdown actions before using this behavior.
180
181Read [programming](references/programming.md) and
182[execution/testing](references/executing-scripts.md).
183
184## Python integration, pinned to R2026a
185
186- R2026a supports 64-bit CPython 3.9-3.13 for MATLAB Interface to Python,
187 MATLAB Engine for Python, and MATLAB Compiler SDK for Python.
188- The current R2026a PyPI package reviewed here is
189 `matlabengine==26.1.12` (released 2026-05-08). It requires an installed
190 R2026a; MATLAB Runtime alone is insufficient. R2026a also ships a
191 preinstalled Engine distribution under one named `matlabroot` path.
192- Package installation does not grant MATLAB or toolbox licenses. Configure
193 one named interpreter/executable; do not print the full environment,
194 `PATH`, `PYTHONPATH`, or credentials.
195- `pyenv` controls MATLAB-to-Python interpreter selection. In-process Python
196 generally requires restarting MATLAB to switch; out-of-process Python can
197 be terminated and reconfigured.
198- Starting Engine is an explicit execution action:
199 `matlab.engine.start_matlab()` starts a MATLAB process and can check out a
200 license. Never call it merely to probe availability.
201- Verify conversion semantics for NumPy arrays, pandas DataFrames,
202 tables/timetables, strings/missing values, datetime/duration, dictionaries,
203 shape/order, and unsupported sparse/object/categorical cases.
204
205Read [Python integration](references/python-integration.md).
206
207## Local helper CLIs
208
209Every helper is network-free, bounded, symlink-rejecting, and nonexecuting.
210Run from this skill directory with Python 3.11+. Bash is allowed only to invoke
211these Python CLIs and validation commands; never use it to execute a generated
212MATLAB/Octave argv plan or untrusted artifact.
213
214| Helper | Purpose |
215|---|---|
216| `scripts/plan_batch_command.py` | Produce reviewed MATLAB/Octave argv; never execute |
217| `scripts/scan_m_code.py` | Scan `.m` text and flag opaque `.mlx`/MEX risks |
218| `scripts/validate_project_manifest.py` | Validate paths and declared product/license status |
219| `scripts/inventory_mat_file.py` | Header/metadata inventory; never call `loadmat` |
220| `scripts/plan_python_compatibility.py` | Check R2026a CPython/Engine compatibility |
221| `scripts/reproducibility_report.py` | Hash named local artifacts and emit a bounded report |
222| `scripts/generate_function_scaffold.py` | Dry-run or create function and unit-test scaffolds |
223
224```bash
225python scripts/scan_m_code.py path/to/source --root path/to/project
226python scripts/plan_batch_command.py matlab script path/to/main.m --root path/to/project
227python scripts/validate_project_manifest.py project-manifest.json --root path/to/project
228python scripts/inventory_mat_file.py data.mat --root path/to/project
229python scripts/plan_python_compatibility.py --python-version 3.13
230python scripts/reproducibility_report.py --root path/to/project --file src/analyze.m
231python scripts/generate_function_scaffold.py analyzeSignal --root path/to/project
232```
233
234The scaffold generator defaults to dry-run; writing requires `--write` and
235refuses collisions. SciPy and h5py are optional inventory backends; if
236authorized, add exact reviewed versions to the caller's project lockfile.
237They are not required for `--help` or header-only inventory, and this skill
238does not perform package installation.
239
240## References
241
242- [Programming, workspaces, projects, analysis, tests](references/programming.md)
243- [Matrices, indexing, types, missingness, performance](references/matrices-arrays.md)
244- [Numerical methods, tolerances, RNG, toolbox boundaries](references/mathematics.md)
245- [Graphics and `exportgraphics`](references/graphics-visualization.md)
246- [Import/export, tables/timetables, MAT semantics and safety](references/data-import-export.md)
247- [MATLAB/Octave command-line execution and migration](references/executing-scripts.md)
248- [MATLAB and Python interoperability](references/python-integration.md)
249- [GNU Octave 11.3.0 compatibility differences](references/octave-compatibility.md)
250
251Bundled JSON assets are the [project manifest](assets/project_manifest_template.json),
252[reproducibility manifest](assets/reproducibility_manifest_template.json), and
253[R2026a Python table](assets/python_compatibility_r2026a.json). There is no
254`templates/` directory and no Markdown file is loaded from `assets/`;
255local-link tests enforce this package contract.
256
257## Primary sources (verified 2026-07-23)
258
259- [MATLAB R2026a documentation](https://www.mathworks.com/help/matlab/)
260- [MATLAB R2026a release notes](https://www.mathworks.com/help/matlab/release-notes.html)
261- [R2026a system requirements](https://www.mathworks.com/support/requirements/matlab-system-requirements.html)
262- [Python compatibility by release](https://www.mathworks.com/support/requirements/python-compatibility.html)
263- [MATLAB Engine installation](https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html)
264- [GNU Octave 11.3.0 release](https://octave.org/)
265- [GNU Octave current manual](https://docs.octave.org/latest/)