skills/matlab/SKILL.md
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.
unknown until confirmed.See Octave compatibility and execution/product boundaries.
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.
.m files, opaque artifacts, project paths,
required products, and MAT headers before any runtime loads them.arguments block for
automation. Use scripts only for controlled orchestration and live scripts
for reviewed interactive narratives..mlx) mix code and rich output but are not plain-text
review artifacts. Export reviewed code to .m for static inspection.clear all, broad addpath(genpath(...)), dependence on pwd, global
variables, and silent name shadowing. Use project roots and fullfile.arguments blocks. Remember that
type declarations can convert inputs; validators check without converting.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.
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.timeit or the profiler.== or a magic multiple of eps.RandStream substreams for
independent parallel work; do not use time-based rng("shuffle") for a
reproducibility claim.Read arrays and mathematics.
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.timetable additionally has row times. Sort, validate time zones and
uniqueness, then use retime/synchronize intentionally.NaN, NaT, <missing>,
<undefined>, and empty character vectors. Integer and logical arrays have
no standard missing sentinel.Read data import/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.
save default; matfile creates 7.3 by default.
Versions 4/6/7/7.3 differ in types, compression, and per-variable limits.Read data import/export.
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.codeIssues; legacy text workflows can use checkcode)
and codeCompatibilityReport before migration.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.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.
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.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.matlab.engine.start_matlab() starts a MATLAB process and can check out a
license. Never call it merely to probe availability.Read Python integration.
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.
exportgraphicsBundled 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.