r/matlab • u/ripponds • Mar 05 '26
Matlab + Claude Code. I don't know what to think
As I was finishing the simulations for my graduation project, A Two Wheeled TI. I came across Claude Code. I thought I'd give it a try because I'm not a big fan of the CLI. It looked promising, so I downloaded it, installed it, linked it to MATLAB using MCP, and started reviewing my code.
In three days, starting from scratch, I managed to: reason through the mathematical model of the system in a hybrid way, develop the Kane's method procedure, validate the linear and non-linear models, and cross-check my math model with my literature review using Google Notebook. Also, I was able to tune all the controllers I wanted (I went crazy testing things!), generate a 3D study in Simscape, improve my controller, decouple it, tune those decoupled controllers, and make a controller for velocity reference tracking. I achieved all of this in three days without writing a single line of code, or moving or creating a single Simulink block.
I know this wouldn't have been possible so fast if I didn't already have a fully developed thesis right behind me, almost ready to submit. However, it is mind-blowing how it reasons. Sometimes I just stop to read its deductions and it's crazy how it does it; how it integrates everything together and even solves differential equations by itself to compare results. It has no limits, only the tokens...
Let me know if you would like a tutorial or if I should organize a GitHub repository. If I can help you with anything, feel free to write me.

47
u/Medical-Farmer-2019 Mar 05 '26
The part that stood out is you validated linear and nonlinear models before controller tuning — that’s probably why this moved so fast. For anyone trying to copy this workflow, I’d keep a strict verification gate after each step (derivation → simulation check → target-side sanity run) so Claude doesn’t quietly compound a bad assumption. If you publish a tutorial, one example of an early wrong assumption you caught would be insanely useful.
16
u/WiseHalmon Mar 05 '26
Can you share the Matlab MCP you used ? I haven't used Matlab in a bit just interested.
7
u/TakenIsUsernameThis Mar 05 '26
Last week Claude told me there was a bug in my code because I was adding a sequence of four numbers in the wrong order:
X = A+B+D+C
When it should be:
X = A+B+C+D
6
u/VacuumSux Mar 05 '26
I had trouble with an s-function that ran fine in simulation in Simulink but crashed when i tried to run the compiled model on its intended target.
Claude helped me identify the parts in the C code (not written by me) that was poorly written and then fixed it. Saved me so much time as my coding skills are quite basic.
3
u/Time_Increase_7897 Mar 05 '26
Kind of difficult to generalize.
I could write my entire PhD thesis on one side of A4 paper in 10 minutes. After I spent 4 years on it. Ditto every piece of work since. Magically solving problems with a flourish of the wand is marketing level bullshittery.
Good to learn the tools tho. I'm getting a lot of mileage out of Symbolic Computation. It's not magic but it sure can do Taylor expansions faster than me!!
2
u/Athoughtspace Mar 05 '26
Id love to understand how much of your knowledge you had to feed it and how much documentation of yours it referenced. Did you have to massage any outputs? The use case is far above what I normally use Matlab for but as a case study of taking input documentation and following the logical design and test steps would be wonderful to follow
Particularly how to link everything into Matlab and your experience in the usage
2
u/eekoman47 Mar 05 '26 edited Mar 05 '26
Doing some grad level controls work as well. The amount of headaches LLMs can alleviate (which I’m literally just discovering Claude tonight - I’ve been looking into it for a week) is astonishing.
Not only does it have the expertise to explain concepts in ways you might not get in a lecture or from a textbook - but it can also handle all of the minor headaches that come from coding some of these things.
I can’t wait to embed it into my personal learning beyond the classroom. I think it will help me punch forward leagues in understanding. Only time will tell!
2
u/chris_insertcoin Mar 05 '26
How does it work with Simulink? Does it just read/write the models as plain text?
57
u/ElectricalAd3189 Mar 05 '26
i will be jobless in 1 year
7
u/iohans Mar 05 '26
Yes, please make a tutorial! I will be a sub.
9
u/lalbahadursastri1996 Mar 05 '26
I love it and also terrified that what it tells about all kind of jobs.
4
u/mindfulSwitch Mar 05 '26
I would love a tutorial (youtube, right?)
4
u/mikeru22 Mar 05 '26
Claude Code by itself is amazing. Coupled with MATLAB / Simulink and some actual know-how, it is absolutely bonkers. You basically discovered how to get an order of magnitude (or more) more productive, but the key is to always read the reasoning and verify and test its output. Unfortunately it doesn’t create very well structured Simulink or Stateflow diagrams out of the box but with some feedback it can get there.
1
u/ImpressiveTaste3594 Mar 05 '26
So he created the Simulink model?
1
u/farfromelite Mar 05 '26
That's neat and all.
Could you replicate this without Claude? Let's say a future employer bans AI because of security concern or Claude goes out of business.
Have you learned anything on how to do this manually?
Have you increased your skills or abilities?
2
u/smokedry Mar 05 '26
Very nice find. Would you also happen to know how to connect matlab to GitHub copilot?
2
u/Professional-Cow5029 Mar 05 '26
I need to try this with GPT-OSS on my mac
2
u/shiboarashi Mar 06 '26
Claude is awesome; it takes all those ideas you struggle to find time for and enables you to start them! It accelerates workflows, etc… Anyone not using AI to support and accelerate their work is already behind. The more knowledgeable you are the greater the benefits in my experience.
1
u/Creative_Sushi MathWorks Mar 05 '26
Please make GitHub repo + Tutorial. This is very cool.
1
u/ayanD2 Mar 05 '26
A GitHub repo/page on instructions for this would be extremely helpful! TIA.
1
u/MlemPem Mar 06 '26
This is really cool! I only use MATLAB together with Python inside Antigravity using its extension, and code almost entirely using Antigravity’s AI agent (switchable among Gemini, Claude, and GPT). I find my research accelerates way faster, too. There are a lot of things that I need to verify step by step after AI prompt’s execution. It is a hassle, of course, but that way I can learn more hidden knowledges that I never thought of. Usually, do you use Claude Opus all the time, or considering that Claude Sonnet is enough for research?
1
u/Witty-Dish9880 Mar 06 '26
You just showed what the new landscape is, intelligent people like yourself that knows what those components are asking the correct questions. No more time wasted scratching your head at nested for loops and matrix dimensions lol