Deploys MATLAB-generated code to embedded hardware using Embedded Coder. Covers ERT configurations, PIL/SIL verification, disabling dynamic memory allocation, and hardware-specific code generation for microcontrollers.
Ships in code-generation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Configure MATLAB Coder with Embedded Coder for production-quality code generation targeting embedded hardware, and verify correctness with processor-in-the-loop (PIL) testing.
matlab-deploy-embedded-ai; for the full AI compression and model-loading workflow, trigger matlab-deploy-embedded-ai firstcodegen workflowscfg = coder.config("lib", "ecoder", true);
The "ecoder", true flag creates an ERT-based (Embedded Real-Time) configuration
that generates production-quality code with no OS dependencies.
With coder.hardware:
cfg.Hardware = coder.hardware("STM32F746G-Discovery");
Without the support package, configure hardware manually:
cfg.HardwareImplementation.ProdHWDeviceType = 'ARM Compatible->ARM Cortex-M';
cfg.HardwareImplementation.ProdBitPerFloat = 32;
cfg.HardwareImplementation.ProdBitPerDouble = 64;
See references/supported-hardware.md for the full list of supported boards and
their constraints.
cfg.EnableDynamicMemoryAllocation = false;
cfg.StackUsageMax = 512;
EnableDynamicMemoryAllocation = false — disables malloc/free for targets
where heap is unavailable or non-deterministic. All arrays must be bounded at
compile time.StackUsageMax — set based on target SRAM. The code generation report shows
actual usage after compilation.For entry-points that use deep learning inference (invoke, predict):
cfg.DeepLearningConfig = coder.DeepLearningConfig('none');
cfg.LargeConstantGeneration = "KeepInSourceFiles";
DeepLearningConfig('none') — generates C with no external DL library dependencies
(MKL-DNN, cuDNN, TensorRT). Required for bare-metal targets. Without this, codegen
may attempt to link an unavailable library and fail.LargeConstantGeneration = "KeepInSourceFiles" — keeps weight constants in source
files rather than separate data files. Needed for bare-metal targets where external
data file linking is unsupported.SIMD vectorization for embedded ARM targets:
cfg.InstructionSetExtensions = 'Neon v7'; % ARM Cortex-A (128-bit, 4x float32)
| Target | Value | Notes |
|---|---|---|
| ARM Cortex-A (Raspberry Pi) | 'Neon v7' | 128-bit SIMD |
| ARM Cortex-M | Do not set — use CodeReplacementLibrary instead | Different mechanism |
For non-embedded targets (Intel x86-64 and the full InstructionSetExtensions
ladder), OptimizeReductions, and OpenMP, see the matlab-generate-code skill.
For the MATLAB Coder ↔ Simulink Coder property naming duality, see
references/simulink-config.md.
Code replacement library (CRL) — routes supported ops to vendor-optimized math library implementations.
On Cortex-A: set BOTH InstructionSetExtensions AND a non-SIMD CodeReplacementLibrary.
They target different layers. ISE emits NEON SIMD intrinsics inline for
vectorizable loops in generated code. A non-SIMD CRL routes higher-level math
ops — trig, filtering, matrix — to library implementations you don't have to
generate. ARM Cortex-A CMSIS maps to the ARM CMSIS-DSP library (hand-tuned
Cortex-A kernels shipped by ARM); it does not itself emit NEON, so it composes
with an explicit InstructionSetExtensions = 'Neon v7'. Setting only one of
ISE or CRL leaves performance on the table:
cfg.HardwareImplementation.ProdHWDeviceType = 'ARM Compatible->ARM Cortex-A';
cfg.InstructionSetExtensions = 'Neon v7'; % SIMD intrinsics (also shown in §4 above)
cfg.CodeReplacementLibrary = 'ARM Cortex-A CMSIS'; % non-SIMD CRL — routes math ops to CMSIS-DSP
For Cortex-M, select the CRL matching your compiler (e.g. 'ARM Cortex-M' for
generic; vendor-specific CRLs are shipped with the corresponding support
package). Cortex-M does not use InstructionSetExtensions.
OpenMP — enable on multi-core targets (Cortex-A); disable on single-core (Cortex-M — no OS/threading support, will fail to compile):
cfg.EnableOpenMP = true; % multi-core targets (Cortex-A)
cfg.EnableOpenMP = false; % single-core targets (Cortex-M)
PIL compiles the generated code, deploys it to the physical board, sends test vectors, and compares outputs against MATLAB. This catches precision differences, stack overflows, and memory issues that SIL cannot detect.
Cortex-M (serial transport):
cfg.VerificationMode = "PIL";
cfg.Hardware.PILInterface = "Serial";
cfg.Hardware.PILCOMPort = "COM4"; % adjust to your system
Cortex-A / Raspberry Pi (SSH transport):
cfg.VerificationMode = "PIL";
cfg.Hardware = coder.hardware("Raspberry Pi");
cfg.Hardware.DeviceAddress = "192.168.1.10";
cfg.Hardware.Username = "<your-pi-username>";
cfg.Hardware.Password = "<your-pi-password>";
cfg.Hardware.BuildDir = "/home/pi/mymodel"; % optional: defaults to /home/pi/MATLAB_ws/<release>
Pi PIL runs over SSH (not serial). The support package uses DeviceAddress,
Username, and Password to establish the SSH connection. BuildDir specifies
where the compiled binary is deployed on the target; if omitted, defaults to
/home/pi/MATLAB_ws/<release>/. Do not set PILInterface or PILCOMPort — those
are for serial-connected bare-metal boards only.
cfg.TargetLang = "C";
codegen -config cfg -args {inputArgs} myEntryPoint
For confidence in deployment, follow this sequence:
cfgSil = coder.config("lib", "ecoder", true);
cfgSil.VerificationMode = "SIL";
codegen -config cfgSil -args {inputArgs} myEntryPoint
| Property | Values | Purpose |
|---|---|---|
VerificationMode | "PIL", "SIL", "None" | Enable in-the-loop verification |
Hardware | coder.hardware(boardName) | Select target board |
Hardware.PILInterface | "Serial" | PIL communication type |
Hardware.PILCOMPort | "COM4", "/dev/ttyACM0" | Serial port |
EnableDynamicMemoryAllocation | true (default), false | Master switch for heap |
DynamicMemoryAllocationThreshold | numeric (bytes), default 65536 | Arrays above this use heap |
LargeConstantGeneration | "KeepInSourceFiles", "WriteOnlyDNNConstantsToDataFiles" | Where to put large constants |
StackUsageMax | numeric (bytes) | Stack limit for generated code (Simulink: MaxStackSize) |
EnableOpenMP | boolean | OpenMP multi-threading (Simulink: MultiThreadedLoops) |
CodeReplacementLibrary | "ARM Cortex-A CMSIS", "GCC ARM Cortex-A" (SIMD), "ARM Cortex-M", … | Vendor-optimized op replacements. GCC ARM Cortex-A is a SIMD CRL — do not pair with an explicit ISE. MATLAB warns it is not recommended; use "ARM Cortex-A CMSIS" instead |
TargetLang | "C", "C++" | Output language |
Simulink Coder path (
slbuild): properties in the "Simulink:" column above are set viaset_param(modelName, 'PropertyName', value)directly on the model name. Seereferences/simulink-config.mdfor the full Simulink Coder property mapping and code examples.
| Mistake | Why It's Wrong | Correct Approach |
|---|---|---|
DynamicMemoryAllocation = "Off" | Wrong property name and type | EnableDynamicMemoryAllocation = false (boolean) |
| Skipping SIL before PIL | PIL failures on hardware are harder to debug | Always validate with SIL first |
Not setting StackUsageMax | Default may exceed target SRAM | Set explicitly based on hardware constraints |
Using cfg = coder.config("lib") without "ecoder", true | Creates a generic config, not ERT-based | Always pass "ecoder", true for embedded targets |
coder.config("lib", "ecoder", true) for embedded targetsDynamicMemoryAllocation (wrong property name — it's EnableDynamicMemoryAllocation)TargetLang = "C" for Cortex-M targets (smaller code footprint)references/supported-hardware.md — board specs, support packages, and PIL interface detailsreferences/simulink-config.md — Simulink Coder property naming, set_param patterns, and slbuild code examplesmatlab-generate-code — generic codegen foundation: coder directives, screener, MEX generation, SIL, config tuning, SIMD/OpenMP for non-embedded targetsmatlab-deploy-ai-model — full AI model codegen pipeline (load, verify, generate MEX/lib)Copyright 2026 The MathWorks, Inc.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
matlab, embedded-coder, pil, sil, code-generation, microcontroller
5 skills in this plugin
/matlab-deploy-ai-modelGenerate C/C++ or CUDA code from an AI model (PyTorch, LiteRT) using MATLAB Coder or GPU Coder. Use when the user wants to integrate an AI model into an application with code generation as the end goal — generating MEX, CUDA MEX, static library, dynamic library, or executable — or using the model in Simulink for simulation and code generation. Covers PyTorch ExportedProgram (.pt2) via loadPyTorchExportedProgram and LiteRT (.tflite) via loadLiteRTModel (R2026a+). Keywords: PyTorch, torch, .pt2, ExportedProgram, loadPyTorchExportedProgram, invoke, codegen, MEX, CUDA, GPU, C, C++, deploy, AI model, deep learning model, LiteRT, TFLite, TensorFlow Lite, Simulink, slbuild, PyTorch ExportedProgram block, MATLAB Function block, dlosslib, loadLiteRTModel.
/matlab-generate-codeGenerate, verify, refine, and accelerate C/C++ or CUDA code from MATLAB with MATLAB Coder, Embedded Coder, GPU Coder, or MATLAB Test. Also covers writing codegen-ready MATLAB code: language constraints, coder.* directives, and optimization patterns. Triggers on: codegen, MEX, deploy MATLAB as C/C++, GPU Coder, coder.screener, coder.config, coder.gpuConfig, coder.typeof, coder.runTest, matlabtest.coder.TestCase, SIL, embedded config, no dynamic memory, EnableMexProfiling, coder.timeit, coder.perfCompare, %#codegen, writing codegen-ready MATLAB, code generation readiness, coder.varsize, coder.unroll, coder.noImplicitExpansionInFunction, coder.ceval, coder.inline, coder.extrinsic, coder.const, coder.classSignature, class codegen limitations, temporal types codegen, DMA-off, stack-only, host-target InstructionSetExtensions, SIMDAcceleration, OptimizeReductions, host SIMD tuning, host OpenMP, codegen performance.
/code-generation:matlab-deploy-embedded-codefrom code-generation
npx claudepluginhub matlab/matlab-agentic-toolkit --plugin code-generationOther plugins' skills for the same job