How to get Claude to write idiomatic MATLAB, not MATLAB-flavored Python
When to use: Any MATLAB authoring task — from scripts to toolboxes.
Prerequisites
- MATLAB R2023b+ recommended — mathworks.com/products/matlab.html
- Skill cloned — git clone https://github.com/matlab/skills ~/.claude/skills/skills
Flow
-
Describe the taskWrite a function that computes the moving-window correlation of two time series — MATLAB, idiomatic.✓ Copied→ Vectorized implementation, correct function signature, docstring
-
Ask for testsAdd MATLAB unit tests using matlab.unittest.✓ Copied→ Tests in a separate file following MATLAB Test conventions
-
ProfileIf this is called in a tight loop, how would you profile and speed it up?✓ Copied→ tic/toc or profile() suggestions, preallocation hints
Outcome: Idiomatic, fast, tested MATLAB code.
Pitfalls
- Claude reaches for Python-style loops — Explicitly ask for vectorized form; reference MATLAB docs style