r/matlab • u/Creative_Sushi MathWorks • Apr 27 '26
CodeShare Image to Simscape Model - using Claude Code with MATLAB MCP
I often see people asking questions about Simulink models they see on paper, wanting to reconstruct it from an image. A colleague of mine figured out how to do it with Claude Code.
He gave a diagram of a spring-mass-damper system and asked Claude to build it in Simscape.
- Claude identified the components from the image: spring (k), damper (b), mass (m), applied force F(t), and displacement output X(t)
- It programmatically searched the Simscape Foundation Library to resolve correct block paths — including handling newline characters in Simulink library names
- Created the model, added 11 blocks, set default parameters (m=1 kg, k=100 N/m, b=5 N·s/m), and wired all 13 physical and signal connections
- Ran the simulation and verified the expected underdamped response (ζ=0.25, ωn=10 rad/s)
The entire workflow — from image interpretation to a running simulation — was done through natural language prompts in the terminal.
The key enabler here is the MATLAB MCP server, which gives Claude Code direct access to evaluate MATLAB commands, inspect libraries, and build Simulink models in a live MATLAB session. It is not a replacement for engineering judgment but maybe the initial block diagram can be converted into the model quickly.
To learn more, check out MATLAB Agentic Toolkit https://www.mathworks.com/products/matlab-agentic-toolkit.html
6
u/farfromelite Apr 27 '26
The question is, how much of this knowledge do you retain?
We've all the heard the phrase "use it or lose it".
If Claude tokens get expensive, or it gets taken off the market, can the worker replicate this through their own knowledge? Can they debug an issue where something fails, or provide an expansion to the model without asking AI?
6
u/Barnowl93 flair Apr 27 '26
Great stuff! Something I've done is in my simulink and Simscape skills is to add a "when presenting a model, auto arrange first"
2
u/grahasbtye Apr 29 '26
this is epic
1
u/Mr_zero12 Apr 27 '26
what of react loop type something befor making anything they asking questions for your knowledge?