How to get Claude to write idiomatic MATLAB, not MATLAB-flavored Python
何時使用: Any MATLAB authoring task — from scripts to toolboxes.
前置條件
- MATLAB R2023b+ recommended — mathworks.com/products/matlab.html
- Skill cloned — git clone https://github.com/matlab/skills ~/.claude/skills/skills
步驟
-
Describe the taskWrite a function that computes the moving-window correlation of two time series — MATLAB, idiomatic.✓ 已複製→ Vectorized implementation, correct function signature, docstring
-
Ask for testsAdd MATLAB unit tests using matlab.unittest.✓ 已複製→ 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?✓ 已複製→ tic/toc or profile() suggestions, preallocation hints
結果: Idiomatic, fast, tested MATLAB code.
注意事項
- Claude reaches for Python-style loops — Explicitly ask for vectorized form; reference MATLAB docs style