Skip to main content
ClaudeWave
ES, Spanish
Skill1.2k estrellas del repoactualizado 6d ago

matlab-generate-code

>

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit /tmp/matlab-generate-code && cp -r /tmp/matlab-generate-code/skills-catalog/code-generation/matlab-generate-code ~/.claude/skills/matlab-generate-code
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Generate Code with MATLAB Coder

Umbrella skill for the MATLAB Coder workflow: generate code, verify it, refine the config, and accelerate with profiled MEX.

## When to Use

- Generating C/C++ or CUDA code from MATLAB functions (MEX, lib, dll, exe)
- Writing new MATLAB code that must be compatible with code generation
- Reviewing existing MATLAB code for codegen readiness or fixing codegen errors
- Configuring codegen settings for specific targets (embedded, speed, readability, safety)
- Verifying generated code matches MATLAB output (coder.runTest, matlabtest.coder.TestCase)
- Profiling and accelerating generated MEX functions
- Using coder.* directives (coder.varsize, coder.const, coder.extrinsic, coder.ceval, etc.)

## When NOT to Use

- Simulink Coder / Embedded Coder Simulink-model workflows
- Generating code for target languages that are not C, C++, or CUDA
- Fixed-Point Designer conversion workflows
- Hand-written MEX C files (not generated by MATLAB Coder)
- General MATLAB programming unrelated to code generation

### Route to a more specific skill

- **Generating code from an AI model** (PyTorch `.pt2` / LiteRT `.tflite` via `loadPyTorchExportedProgram` / `loadLiteRTModel`) → use **matlab-deploy-ai-model**. Return here for the underlying `coder.*` directives, config tuning, and screener/verification.
- **Deploying to physical embedded hardware** (on-target PIL, ERT hardware configs, board selection — STM32 / Raspberry Pi / ARM Cortex) → use **matlab-deploy-embedded-code**. This skill covers host-side codegen, SIL, and config tuning up to hardware targeting.
- **Speeding up interpreted MATLAB by rewriting the M-code** (vectorization, preallocation, caching) → use **matlab-optimize-performance**. This skill's acceleration path assumes you want to compile to MEX/C, not restructure the algorithm.
- **General MATLAB test authoring** (parameterized tests, fixtures, mocking, coverage, CI/CD, App Designer) → use **matlab-write-test**. This skill covers only codegen-equivalence tests (`coder.runTest`, `matlabtest.coder.TestCase`).
- **Modernizing deprecated APIs for currency/maintainability** when code generation is not the goal → use **matlab-modernize-code**. This skill rewrites source only to satisfy codegen constraints, with explicit authorization.

## Routing — load the matching reference file on demand

Pick the workflow that matches the user's intent and read the corresponding `references/*.md`. Each reference file is a deep, self-contained guide; load only what you need rather than carrying all four in context.

| User intent | Load |
|---|---|
| Writing new codegen-compatible MATLAB; reviewing MATLAB for codegen readiness; fixing codegen errors; `%#codegen`; language constraints; type/size rules | `references/write-codegen-ready.md` |
| Understanding a specific `coder.*` directive (coder.varsize, coder.const, coder.inline, coder.unroll, coder.extrinsic, etc.) | `references/write-coder-directives.md` |
| Using MATLAB classes in codegen; class limitations; `coder.classSignature`; handle vs value class restrictions | `references/write-class-limitations.md` |
| Generate C/C++/CUDA code (MEX, lib, dll, exe), specify input types, fix `coder.screener` issues | `references/generate-code.md` |
| Verify generated code matches MATLAB; write `coder.runTest` / `matlabtest.coder.TestCase` tests; SIL setup | `references/verify-code.md` |
| Tune a working config for a deployment goal (embedded / speed / readability / size / safety); SIMD values (SIMDAcceleration, InstructionSetExtensions), OpenMP, OptimizeReductions | `references/refine-config.md` |
| Profile generated MEX, measure `coder.timeit` / `coder.perfCompare`, find hotspots | `references/accelerate-mex.md` |
| Look up a config property's name, availability, or non-obvious behavior | `references/config-properties.md` |

**Disambiguation — "write" vs. "generate" vs. "generate for a class":**
- "Write codegen-ready code" = authoring/reviewing the MATLAB source so it *can* be compiled (`write-codegen-ready.md`)
- "Generate code" = running `codegen` to produce C/C++ from an already-valid function (`generate-code.md`)
- "Generate code for a class" / "generate C++ class" = the user's source is a `classdef` file → load `generate-code.md` (Step 0 handles class entry points via `coder.ClassSignature`). Do NOT default to wrapping the class in a function.
- If both apply (user wants to write a function AND generate code from it), load `write-codegen-ready.md` first, then `generate-code.md`

For requests that span workflows (e.g., "generate MEX, verify it, then speed it up"), load the references in order rather than all at once.

## Out of scope

- **Simulink** Coder / Embedded Coder workflows (these are skill candidates of their own).
- **Non-C, C++, or CUDA target languages** — this skill covers C/C++ and CUDA code generation only
- **Fixed-point conversion** (use Fixed-Point Designer).
- **Hand-written MEX files** — the acceleration guidance assumes MATLAB Coder-generated MEX.
- **`CodeExecutionProfiling` / SIL profiling** with Embedded Coder — out of scope for the acceleration reference.

## Cross-cutting rules

These apply across every workflow. Apply them whether or not you've loaded a per-workflow reference yet.

### Class entry point — use `coder.ClassSignature`, not a wrapper function

When the user's target is a MATLAB class (classdef file) and they want to generate C++ code from it, use `coder.ClassSignature` for direct class code generation. Do NOT create a wrapper entry-point function. This produces a proper C++ class with methods — which is what users mean when they say "generate C++ class."

Load `references/generate-code.md` → Step 0 and `references/write-class-limitations.md` → "Direct class code generation" for the full workflow. The prerequisite `enableCodegenForEntryPointClasses` must run once per session.

Only fall back to a wrapper function if the user's MATLAB version lacks `coder.ClassSignature` (pre-R2026a) or the clas
matlab-access-datafeedSkill

>

matlab-analyze-ams-waveformSkill

Analyze AMS waveform data using Mixed-Signal Blockset utilities: phase noise measurement, clock jitter, anti-aliased resampling, timing measurements, lock time, INL/DNL, ADC/DAC calibration, HSpice import. Use when analyzing time-domain voltage from PLL/VCO/clock simulations, measuring phase noise from variable-step solver output, computing jitter, or resampling non-uniform data.

matlab-analyze-dataSkill

Analyze data using MATLAB. Use when the task involves tables, timetables, time-series data, numeric arrays, sensor matrices, or gridded data — including but not limited to exploring, filtering, sorting, cleaning, transforming, aggregating, smoothing, padding, trimming, and answering questions about data. MATLAB provides extensive, easy-to-use built-in functions for these workflows with no additional products required.

matlab-analyze-dependenciesSkill

Analyze the effective toolbox file set to produce a Dependency Manifest — classify all transitive dependencies as included, product, add-on, or external-unresolved, then present resolution options with tradeoffs. Use after matlab-define-toolbox-api when the spec is approved.

matlab-analyze-emSkill

S-parameters, insertion loss, fields, currents, mesh control, and solver selection for RF PCB performance validation. TRIGGER: user asks to compute S-parameters, analyze insertion/return loss, extract fields or currents, compare MoM vs FEM, or control mesh for any RF PCB component. Invoke BEFORE writing sparameters() or solver code — API is non-obvious. SKIP: designing or creating components (use the specific matlab-design-pcb-* skill), material/stackup setup only (use matlab-manage-pcb-material), optimization sweeps (use matlab-optimize-pcb-design), PDN/IR-drop analysis (use matlab-analyze-pcb-pdn).

matlab-analyze-installed-antennaSkill

Analyze antennas installed on electrically large conducting platforms using MATLAB Antenna Toolbox. Loads platform geometry from STL/STEP/IGES, installs antenna elements, selects electromagnetic solvers (MoM-PO, FMM, MoM), and computes patterns, impedance, coupling, and efficiency. Use when the user wants to model an antenna on a vehicle, aircraft, ship, satellite, or other large structure.

matlab-analyze-pcb-pdnSkill

PDN DC voltage/current analysis, IR drop, design rule checking, and multi-net batch analysis on imported PCB layouts. TRIGGER: user asks about power integrity, PDN analysis, IR drop, voltage distribution, current density, power nets, or design rule checking on a PCB. Invoke BEFORE writing code — the PDN API chain is specialized and non-obvious. SKIP: importing a PCB file (use matlab-read-pcb-layout), EM field/S-parameter extraction (use matlab-analyze-em), material/stackup setup only (use matlab-manage-pcb-material), transmission line design (use matlab-design-pcb-txline).

matlab-analyze-rcsSkill

Calculate and visualize monostatic and bistatic radar cross section (RCS) using MATLAB Antenna Toolbox. Computes RCS of platforms, antennas, and arrays with PO, MoM, and FMM solvers, supporting HH/VV/HV/VH polarization, GPU acceleration, and near-field observation. Use when the user wants to compute, plot, or analyze radar cross section.