<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Artificial Intelligence</title>
	<atom:link href="https://blogs.mathworks.com/deep-learning/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogs.mathworks.com/deep-learning</link>
	<description>Yann is an AI Product Marketing Manager, with past experiences in open-source scientific computing. He wrote a book on &#34;MATLAB with Python&#34; and is now blogging about machine learning, deep learning and interoperability with TensorFlow and PyTorch.</description>
	<lastBuildDate>Wed, 08 Apr 2026 17:34:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
	<item>
		<title>Less Typing, More Creating: MATLAB Copilot Comes to Your Android Phone</title>
		<link>https://blogs.mathworks.com/deep-learning/2026/04/07/less-typing-more-creating-matlab-copilot-comes-to-your-phone/?s_tid=feedtopost</link>
					<comments>https://blogs.mathworks.com/deep-learning/2026/04/07/less-typing-more-creating-matlab-copilot-comes-to-your-phone/#respond</comments>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Tue, 07 Apr 2026 14:07:52 +0000</pubDate>
				<category><![CDATA[Agentic AI]]></category>
		<category><![CDATA[Generative AI]]></category>
		<category><![CDATA[MATLAB Online]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19242</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2026/04/MATLABCopilotOnMobileBlogPost_1.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>






Guest Co-author: Tharikaa Ramesh Kumar, PhD

Tharikaa is the Product Manager for MATLAB Mobile. She holds a PhD in Aerospace Engineering from Auburn University, where she taught... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2026/04/07/less-typing-more-creating-matlab-copilot-comes-to-your-phone/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">
<div>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19243" src="https://blogs.mathworks.com/deep-learning/files/2026/04/tharikaa.png" alt="" width="100" height="100" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Guest Co-author: <a href="https://www.linkedin.com/in/tharikaa-ramesh-kumar/" target="_blank" rel="noopener">Tharikaa Ramesh Kumar, PhD</a></strong>
<h6></h6>
<strong>Tharikaa</strong> is the Product Manager for MATLAB Mobile. She holds a PhD in Aerospace Engineering from Auburn University, where she taught dynamics and systems courses using MATLAB as a graduate instructor.</td>
</tr>
</tbody>
</table>
<br>

<span style="font-size: 14px; font-weight: 400;">I'm excited to share some news that I think will change the way many of you use MATLAB on the go. We've brought </span><a style="font-size: 14px; font-weight: 400;" href="https://www.mathworks.com/products/matlab-copilot.html">MATLAB Copilot</a><span style="font-size: 14px; font-weight: 400;"> to </span><a style="font-size: 14px; font-weight: 400;" href="https://www.mathworks.com/products/matlab-mobile.html">MATLAB Mobile</a><span style="font-size: 14px; font-weight: 400;">, and it's available for now on Android with two features: </span><span style="font-weight: bold;">Copilot Chat</span><span style="font-size: 14px; font-weight: 400;"> and </span><span style="font-weight: bold;">Explain Code</span><span style="font-size: 14px; font-weight: 400;">. </span>

If you've ever been on a commute, in a lecture hall, or out in the field and wished you could quickly prototype an idea in MATLAB, you know the challenge. You pull out your phone, open MATLAB Mobile, and start typing on a small touch keyboard. It works, but it's not exactly the same as sitting at your desk. That's where Copilot comes in.

</div>
<h2></h2>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Why an AI Assistant on Your Phone Changes Things</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Let's be honest: coding on a phone has its limitations. The screen is smaller, the keyboard is touch-based, and switching between your code and documentation is a juggling act. MATLAB Copilot reduces that friction significantly.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">With Copilot Chat, you describe what you want in natural language and get MATLAB code you can run right away. Instead of typing out every function call and argument, you tell Copilot what you need and it writes the code for you. Less typing, more creating!</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here is a bonus: your phone keyboard already has a microphone button for speech-to-text. Tap it, speak your Copilot prompt, and the code appears. You do not even need to type your request. Between voice input and AI-generated code, this is as close to a low-code experience as it gets on a phone. And when you do type, your phone keyboard's predictive text and autocomplete suggestions help you write prompts faster than you would on a desktop keyboard.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">For the many students and educators who use MATLAB Mobile every day, this is especially valuable. Your phone is the one device that's always with you and always charged. It's more personal and more accessible than a laptop. With Copilot on that same device, you get answers and explanations on the spot, right where you are, instead of waiting to get back to a computer.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 382px; height: 802px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/MATLABCopilotOnMobileBlogPost_1.png" alt="" width="382" height="802" /></div>
<h2></h2>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Copilot Chat</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Copilot Chat is a conversational AI assistant built right into MATLAB Mobile. You can access it from the Command Window, the Editor, or the app menu. Ask a question, describe the code you need, or request an explanation. Copilot responds with answers grounded in MathWorks documentation.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here is where it really shines on mobile. Say you've just collected accelerometer data from your phone's sensors using MATLAB Mobile's built-in sensor support. You want to plot the x, y, and z axes on a single figure, but you can't remember the exact syntax. Open Copilot Chat and describe what you're looking for. Copilot generates a ready-to-run snippet that handles the <span style="font-family: monospace;">plot</span> calls, axis labels, and legend for you. Tap to insert the code, hit Run, and you're looking at your data.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">It works just as well for broader questions. If you're wondering how to apply a low-pass filter to audio you recorded on your phone, ask Copilot. Need a quick refresher on how <span style="font-family: monospace;">fft</span> works? Ask Copilot. It handles everything from basic syntax help to signal processing workflows, and every response draws from official MathWorks documentation so the code follows best practices.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">As with all things GenAI, your results will depend on your specific question and context.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;"><div class="row"><div class="col-xs-12 containing-block"><div class="bc-outer-container add_margin_20"><videoplayer><div class="video-js-container"><video data-video-id="6392647109112" data-video-category="blog" data-autostart="false" data-account="62009828001" data-omniture-account="mathwgbl" data-player="rJ9XCz2Sx" data-embed="default" id="mathworks-brightcove-player" class="video-js" controls></video><script src="//players.brightcove.net/62009828001/rJ9XCz2Sx_default/index.min.js"></script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs("mathworks-brightcove-player").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();</script></div></videoplayer></div></div></div></div>
<h2></h2>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Explain Code</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The second feature we're bringing to MATLAB Mobile is Explain Code. Select any block of code in the Editor, tap Explain Code, and get a plain-language overview of what the code does along with a line-by-line walkthrough in the Chat panel.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">On a small screen, dense code can be tough to read. Explain Code helps you make sense of it quickly. Say you open a shared script from MATLAB Drive, maybe a classmate's assignment or an instructor's demo file, and encounter a block of code using <span style="font-family: monospace;">fft</span>, windowing functions, and inverse transforms. Instead of switching apps to search the documentation, select the code and tap Explain Code. Copilot gives you an overview of the block's purpose and annotates each line so you understand not just <span style="font-style: italic;">what</span> the code does, but <span style="font-style: italic;">how</span>.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This is incredibly useful for learning. Students can review code before an exam and actually understand each line. TAs can quickly parse student submissions between classes. Professors can pull up a demo script and get a refresher before a lecture. All from their phone.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;"><div class="row"><div class="col-xs-12 containing-block"><div class="bc-outer-container add_margin_20"><videoplayer><div class="video-js-container"><video data-video-id="6392647020112" data-video-category="blog" data-autostart="false" data-account="62009828001" data-omniture-account="mathwgbl" data-player="rJ9XCz2Sx" data-embed="default" id="mathworks-brightcove-player" class="video-js" controls></video><script src="//players.brightcove.net/62009828001/rJ9XCz2Sx_default/index.min.js"></script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs("mathworks-brightcove-player").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();</script></div></videoplayer></div></div></div></div>
<h2></h2>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">When Will You Use This?</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">The student on the bus.</span> You're reviewing the signal processing examples your professor shared on MATLAB Drive. You select the Fourier transform code block, tap Explain Code, and get a line-by-line breakdown. By the time you arrive, you understand exactly how the frequency domain conversion works.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">The professor between classes.</span> A student messages you about an error in their script. You open MATLAB Mobile, describe the issue to Copilot Chat, and get a suggested fix. Share the chat history directly through your phone's messaging apps, or save it as a .txt file to MATLAB Drive for later reference. No laptop needed.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 355px; height: 743px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/MATLABCopilotOnMobileBlogPost_5.png" alt="" width="355" height="743" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">The engineer in the field.</span> You're collecting magnetometer data with MATLAB Mobile's sensor support and want to visualize the magnetic field direction. You ask Copilot Chat how to create the visualization. It generates the code, you run it on the spot, and you see results immediately.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">And here is the thing: none of this work is stuck on your phone. Every script you create with Copilot syncs to MATLAB Drive, so you can start prototyping on the bus and pick up right where you left off on your desktop. Copilot on your phone is not a separate experience. It is part of the same workflow.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">We hear from students and researchers all the time that their phone is always with them, even when their laptop isn't. Now, MATLAB Copilot is right there too.</div>
<h2></h2>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">How to Get Started</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Getting started takes just a few steps:</div>
<ol>
 	<li><span style="font-weight: bold;">Install or update MATLAB Mobile</span> from the <a href="https://play.google.com/store/apps/details?id=com.mathworks.matlabmobile">Google Play</a> (Android). The app is free to download.</li>
 	<li><span style="font-weight: bold;">Check your MATLAB Copilot license.</span> You'll need a MATLAB Copilot license to use Copilot Chat and Explain Code. Many university campus-wide licenses already include MATLAB Copilot. Check with your institution's MATLAB administrator. Individual and team licenses that include Copilot work as well.</li>
 	<li><span style="font-weight: bold;">Start using it.</span> Open MATLAB Mobile and access Copilot Chat from the Command Window, the Editor, or the app menu. To try Explain Code, select code in the Editor and choose "Explain Code." That's it.</li>
</ol>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">For more details, visit the <a href="https://www.mathworks.com/help/matlab-copilot/">MATLAB Copilot documentation</a> and the <a href="https://www.mathworks.com/products/matlab-mobile.html">MATLAB Mobile product page</a>.</div>
<h2></h2>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Try It Out</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">We've been looking forward to getting this into your hands. Update MATLAB Mobile, open Copilot Chat, and ask your first question. I think you'll be surprised how quickly it becomes part of your workflow.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">We'd love to hear how you're using MATLAB Copilot on Mobile. Drop a comment below or share your experience with <span style="font-weight: bold;">#MATLABMobile</span>.</div>
<div></div>
</div>
<script type="text/javascript">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }</script>

</div><br>]]></content:encoded>
					
					<wfw:commentRss>https://blogs.mathworks.com/deep-learning/2026/04/07/less-typing-more-creating-matlab-copilot-comes-to-your-phone/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Advanced Battery State of Charge Estimation with AI</title>
		<link>https://blogs.mathworks.com/deep-learning/2026/04/06/advanced-battery-state-of-charge-estimation-with-ai/?s_tid=feedtopost</link>
					<comments>https://blogs.mathworks.com/deep-learning/2026/04/06/advanced-battery-state-of-charge-estimation-with-ai/#respond</comments>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Mon, 06 Apr 2026 13:55:44 +0000</pubDate>
				<category><![CDATA[Deep Learning]]></category>
		<category><![CDATA[Embedded AI]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19231</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2026/04/Draft_Articolo_Mathworks_version_1_6.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>








Guest writer: Riccardo Di Dio

Riccardo Di Dio is an Industrial PhD Candidate sharing his time between the University of Pisa and Marelli, working on artificial intelligence... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2026/04/06/advanced-battery-state-of-charge-estimation-with-ai/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<div class="rtcContent">
<div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div>
<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19233" src="https://blogs.mathworks.com/deep-learning/files/2026/04/riccardo-150x150.jpg" alt="" width="100" height="100" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Guest writer: <a href="https://www.linkedin.com/in/ricc-di-dio/" target="_blank" rel="noopener">Riccardo Di Dio</a></strong>
<h6></h6>
<span style="font-weight: bold;">Riccardo Di Dio </span>is an Industrial PhD Candidate sharing his time between the University of Pisa and Marelli, working on artificial intelligence methods for Battery Management Systems. His research focuses on deep learning algorithms for estimating battery internal states such as State of Charge (SOC) and State of Health (SOH), developed using MATLAB and Deep Learning Toolbox.</td>
</tr>
</tbody>
</table>
<h6></h6>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
</div>
<div></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">As a global leader in automotive technology, Marelli is driven by innovation supporting the electrification revolution. This article's aim is to show a cutting-edge solution developed for Battery State of Charge (SOC) estimation using artificial intelligence. Accurate SOC estimation is essential for Battery Management System, directly impacting vehicle performance safety and battery lifespan. Since SOC cannot be measured directly, it must be estimated using available sensor data and advanced modelling techniques. Marelli saw an opportunity to use a data driven approach powered by AI to overcome the limitations of the traditional physical models.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The article describes how the Marelli company developed the AI algorithm using synthetic dataset generated through a Virtual Environment developed using model-based design techniques in MATLAB.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The entire workflow executed using the MathWorks toolchain spans from data generation to embedded device deployment.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 567px; height: 232px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/Draft_Articolo_Mathworks_version_1_1.png" alt="" width="567" height="232" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The MathWorks toolchain was selected due to the following reasons: visual development environment enabled intuitive graphical modeling with blocks, facilitating easy connection between the controls system and the plant model; compatibility with the Hardware in the Loop design for testing the interaction between the software and the embedded device; automatic code generation; possibility of training the algorithm in MATLAB and exporting the trained network to a real-time system.</div>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Data Preparation</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The dataset for training and validation was generated using a virtual environment repeating several times the homologation driving cycle.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 628px; height: 199px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/Draft_Articolo_Mathworks_version_1_2.png" alt="" width="628" height="199" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The Operating Domain Definition (ODD) conditions are:</div>
<ul style="margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;">
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;">new electrochemical cell (cell with a State of Health equal to 100%)</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;">constant temperature of 25 C and 35 C</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;">ideality of the current sensor and the voltage sensor %[text] The inputs chosen for estimating the state of charge are the cell voltage, the cell current and the temperature. The reference state of charge is calculated using the Coulomb counting equation. All the inputs were normalized considering the operating limits of the cell (cut-off voltage, maximum or minimum current and temperature).</li>
</ul>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">AI Modeling</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Due to the time-related evolution of a battery's SOC, the Long Short Term Memory (LSTM) architecture was selected as the neural network. LSTM networks are particularly well-suited for capturing time-dependent patterns and sequential relationships, making them ideal for accurately estimating SOC based on historical sensor readings. The data samples were not fed to the networks individually; instead, a temporal observation window was considered.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The network was designed and trained using the Deep Learning Toolbox, provided by MathWorks, due to its powerful features for building, training and evaluating neural network models within the MATLAB environment.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">A grid search technique was used to find the best performance and in particular to select the best number of neurons, the learning rate and the window size.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 602px; height: 232px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/Draft_Articolo_Mathworks_version_1_3.png" alt="" width="602" height="232" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The Deep Learning Toolbox facilitates advanced hyperparameter tuning, making it efficient to develop and optimize complex deep learning architectures.</div>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Real-Time Simulation</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The trained network was exported to the Simulink environment to run Real-Time Testing based on different driving cycles for testing and validation, both inside and outside the ODD conditions.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 692px; height: 139px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/Draft_Articolo_Mathworks_version_1_4.png" alt="" width="692" height="139" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The performance of the developed networks were evaluated considering the following metrics: Root Mean Square Error (RMSE), Mean Absolute Percentage Error (MAPE) and Mean Absolute Error (MAE), defined as:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="vertical-align: -72px;">$ \begin{array}{ll} \mathrm{RMSE} &amp;= \sqrt{\frac{1}{N} \sum_{k=1}^{N} \left( Y_{\mathrm{predicted},k} - Y_{\mathrm{true},k} \right)^2} \\ \mathrm{MAE} &amp;= \frac{1}{N} \sum_{k=1}^{N} \left| Y_{\mathrm{predicted},k} - Y_{\mathrm{true},k} \right| \\ \mathrm{MAPE} &amp;= \frac{100}{N} \sum_{k=1}^{N} \left| \frac{Y_{\mathrm{predicted},k} - Y_{\mathrm{true},k}}{Y_{\mathrm{true},k}} \right| \end{array} $</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The algorithm was validated using a drive cycle different from the WLTP employed for training and validation, in order to assess its robustness and generalization across varied and realistic operating scenarios. The performance achieved is reported in the table below.</div>
<table style="margin: 3px; border: 0.666667px solid #bfbfbf; border-collapse: collapse;">
<tbody>
<tr style="background-color: #f5f5f5;">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">RMSE <span class="comment"></span></div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">MAPE <span class="comment"></span></div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">MAE <span class="comment"></span></div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">1 Simulation WLTP, no aging, ideal current and voltage sensors, 25 C</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">0.29</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">0.44</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">0.22</div></td>
</tr>
</tbody>
</table>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Compression</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">At this stage, the network contained over 10,000 parameters. To address this, a compression technique based on network projection was applied, reducing the number of parameters by 70% while ensuring that the performance of the algorithm remained uncompromised for real-world deployment.</div>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Deployment</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The last step is the C code generation of the network using Embedded Coder and the integration of the AI algorithm into Marelli's BMS architecture.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The AI algorithm embedded on a real Battery Management System hardware was tested in a Hardware-in-the-Loop (HIL) environment, which enables realistic integration between simulation and physical hardware. In this setup, the virtual environment representing the battery system dynamics was deployed directly onto the processor board of the simulator. The simulator was responsible for generating representative signals for key parameters such as voltage, current, and temperature. These signals were converted from digital to analog format using dedicated DACs and sent to the embedded device, which hosts the AI algorithm. The internal software variables of the AI algorithm were continuously monitored using ETAS INCA, allowing direct access to algorithm outputs and internal states.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 752px; height: 473px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/Draft_Articolo_Mathworks_version_1_5.png" alt="" width="752" height="473" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The results recorded by INCA are reported in the figure below.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 594px; height: 283px;" src="https://blogs.mathworks.com/deep-learning/files/2026/04/Draft_Articolo_Mathworks_version_1_6.png" alt="" width="594" height="283" /></div>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Conclusion</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The application of AI techniques to the estimation of highly nonlinear parameters such as battery SOC has proved a powerful alternative to more classic approaches. The compression of the model enables its implementation in a real production use case. The MATLAB toolchain has provided a single workflow which has enabled accelerated design and implementation of this program - from concept to on-target implementation.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
</div>
<script type="text/javascript">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }</script>]]></content:encoded>
					
					<wfw:commentRss>https://blogs.mathworks.com/deep-learning/2026/04/06/advanced-battery-state-of-charge-estimation-with-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Automate the Documentation of Your MATLAB Analysis with Agentic AI</title>
		<link>https://blogs.mathworks.com/deep-learning/2026/02/09/automate-the-documentation-of-your-matlab-analysis-with-agentic-ai/?s_tid=feedtopost</link>
					<comments>https://blogs.mathworks.com/deep-learning/2026/02/09/automate-the-documentation-of-your-matlab-analysis-with-agentic-ai/#comments</comments>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Mon, 09 Feb 2026 22:04:18 +0000</pubDate>
				<category><![CDATA[Agentic AI]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19084</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2026/02/blog_post_updated_draft_livescript_6.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>







Co-author: Rohan Amarapurkar

Rohan Amarapurkar is the product manager for the MATLAB Desktop and Editor. Rohan holds a Master's in Electrical Engineering from USC and previously... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2026/02/09/automate-the-documentation-of-your-matlab-analysis-with-agentic-ai/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div>
<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19086" src="https://blogs.mathworks.com/deep-learning/files/2025/12/rohan-150x150.jpg" alt="" width="100" height="100" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Co-author: <a href="https://www.linkedin.com/in/rohan-amarapurkar/" target="_blank" rel="noopener">Rohan Amarapurkar</a></strong>
<h6></h6>
<span style="font-weight: bold;">Rohan Amarapurkar</span> is the product manager for the MATLAB Desktop and Editor. Rohan holds a Master's in Electrical Engineering from USC and previously was a UX Researcher at MathWorks.</td>
</tr>
</tbody>
</table>
<h6></h6>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This is a scenario that I shared with Rohan to get his advice: you finish an analysis in MATLAB, the plots look great, and now you need to share it with your team. So you start the tedious dance—export to PDF, copy the figures, write up a README, hope you didn't forget anything. And then someone asks you to tweak one parameter, and the whole process starts again.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">There is now a more elegant solution, and in this blog post I am going to introduce a workflow that lets AI do the heavy lifting. With the <a href="https://www.mathworks.com/products/matlab-mcp-core-server.html">MATLAB MCP Core Server</a> and a few well-crafted prompts, you can go from analysis to a beautifully documented GitHub repository in minutes.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<table style="margin: 3px; border: 0.666667px solid #bfbfbf; border-collapse: collapse;">
<tbody>
<tr style="background-color: #f5f5f5;">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">What's new</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Why it matters</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">AI-driven documentation workflow using MCP</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Your analysis, figures, and narrative stay in sync automatically</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Plain-text Live Script format (R2025a)</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Finally, meaningful Git diffs for Live Scripts</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Export to Markdown with embedded outputs</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">GitHub renders your analysis as a professional README</div></td>
</tr>
</tbody>
</table>
<h6></h6>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">The documentation problem</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Let's admit it: documentation is often an afterthought. We write code, iterate on our analysis, and by the time it works, we're ready to move on. But good documentation is what separates a throwaway script from a reusable, shareable piece of work—especially if you're a researcher sharing publications, a student building your portfolio or an engineer looking to share your analysis with a colleague (or maybe your future self).</div>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Starting point: your existing analysis</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Most of us don't start from a blank page. We have a script that already works. Let me show you what I mean. Here's a simple analysis of the power outage dataset that ships with MATLAB (<span style="font-family: monospace;">outages.csv</span>):</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" class="imageNode aligncenter" style="vertical-align: baseline; width: 800px;" src="https://blogs.mathworks.com/deep-learning/files/2026/02/blog_post_updated_draft_livescript_1.png" alt="" width="800" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">It works. The plots look great. But it's just a script — no headings, no explanation of what we're finding, no narrative that a colleague could follow. This is where the MATLAB MCP Core Server comes in.</div>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Why plain-text Live Scripts change the game</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Before we dive into the workflow, let me explain why it's possible now, and why Rohan's team was instrumental in enabling it.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">When we talked to Live Script users, one pain point came up again and again: the binary <span style="font-family: monospace;">.mlx</span> format didn't play well with modern development workflows. You couldn't get meaningful diffs in Git. You couldn't open your scripts in VS Code or your favorite text editor. And if the file got corrupted, you were often out of luck.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">With the new plain-text format introduced in R2025a, Live Scripts are now stored as <span style="font-family: monospace;">.m</span> files with Markdown-based markup in comments. Here's what that looks like:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" class="imageNode aligncenter" style="vertical-align: baseline; width: 809px;" src="https://blogs.mathworks.com/deep-learning/files/2026/02/blog_post_updated_draft_livescript_2.png" alt="" width="809" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; color: #212121; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; text-align: left;">The key benefits:</div>
<ul style="margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;">
<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left;"><span style="font-weight: bold;">Git-friendly</span>: You can now see exactly what changed between commits</li>
<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left;"><span style="font-weight: bold;">Editor-agnostic</span>: Open and edit in VS Code, Notepad++, or any text editor</li>
<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left;"><span style="font-weight: bold;">AI-friendly</span>: Large language models can generate and modify plain-text Live Scripts directly</li>
</ul>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This last point is what makes the agentic workflow possible. An AI agent can read your existing script, restructure it as a Live Script in plain text, and MATLAB opens it seamlessly in the Live Editor with full formatting.</div>
</div>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">The automated documentation workflow</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Now let me walk you through the complete workflow. I'll be using Claude Code with the MATLAB MCP Core Server, but this works with any MCP-compatible client.</div>
<h4 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;">Step 1: Convert your script to a Live Script using skills</h4>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here's the key insight: you don't need to write a Live Script from scratch. You can hand your existing analysis to an AI agent and ask it to transform it.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The <a href="https://github.com/matlab/skills">matlab/skills</a> repository contains curated skill templates for various MATLAB workflows. For generating properly formatted plain-text Live Scripts, point your AI assistant to the <span style="font-family: monospace;">matlab-live-scripts</span> skill.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The concept of <a href="https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview">Agent Skills</a> introduced first by Anthropic in Claude enables "lazy-loading" of context in your agentic conversation (think Neo in The Matrix who "knows kung-fu" after getting a single file upload). We have shared a few MATLAB specific skills in <a href="https://github.com/matlab/skills">github.com/matlab/skills</a>.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here's an example prompt you might use:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-plain" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">Using the matlab-live-script skill from github.com/matlab/skills,</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">convert my outage_analysis.m script into a plain-text Live Script.</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">Add section headings, narrative explanations of what each plot reveals,</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">and a summary of findings.</span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The AI reads your existing code, understands the analysis, and generates a <span style="font-family: monospace;">.m</span> file with the correct markup syntax—section headers using <span style="font-family: monospace;">%[text] ## Title</span>, explanatory text between code blocks, and the required appendix closure. Your analysis logic stays the same; it just gets wrapped in a professional narrative.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" class="imageNode aligncenter" style="vertical-align: baseline; width: 800px;" src="https://blogs.mathworks.com/deep-learning/files/2026/02/blog_post_updated_draft_livescript_3.png" alt="" width="800" /></div>
</div>
<div>
<h4 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;">Step 2: Review the results in the Live Editor</h4>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">After generating the Live Script, open it in MATLAB to verify everything looks right. The figures will be embedded inline with your code and narrative once you run the script. You'll see your outage histograms, scatter plots, and box charts rendered beautifully alongside the explanatory text that the AI generated.</div>
<div></div>
</div>
<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode aligncenter" style="vertical-align: baseline; width: 800px; height: 529px;" src="https://blogs.mathworks.com/deep-learning/files/2026/02/blog_post_updated_draft_livescript_4.png" alt="" width="800" height="529" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This is also where you can make adjustments. Maybe you want to tweak a plot title, add a finding the AI missed, or reorganize a section. The plain-text format means any edits show up cleanly in version control.</div>
<h4 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;">Step 3: Export to Markdown</h4>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Now for the magic. MATLAB's <span style="font-family: monospace;">export</span> function (R2023b+) can convert your Live Script to Markdown:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-matlab" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">export(<span style="color: #a709f5;">'outage_analysis.m'</span>, <span style="color: #a709f5;">'README.md'</span>, <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> Format=<span style="color: #a709f5;">'markdown'</span>, <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> EmbedImages=false, <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> IncludeOutputs=true)</span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Setting <span style="font-family: monospace;">EmbedImages=false</span> creates a <span style="font-family: monospace;">README_media/</span> folder with your figures as separate files—which is what you want for GitHub. The Markdown file references them with relative paths, and GitHub renders everything beautifully.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 801px; height: 527px;" src="https://blogs.mathworks.com/deep-learning/files/2026/02/blog_post_updated_draft_livescript_6.png" alt="" width="801" height="527" /></div>
<h4 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;">Step 4: Push to GitHub or GitLab</h4>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The final step is committing your work to version control. Whether you're a researcher sharing your publications or a student building your portfolio—GitHub is the natural choice. GitLab works just as well.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Your repository structure will look like this:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-plain" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">outage-analysis/</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">├── README.md ← Exported from Live Script</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">├── README_media/ ← Figures referenced by README</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">│ ├── figure_0.png</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">│ ├── figure_1.png</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">│ └── figure_2.png</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">├── outage_analysis.m ← Plain-text Live Script (source)</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">└── .gitattributes</span></div>
</div>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Putting it all together</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The complete workflow in one AI conversation might look like this:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Each step triggers the appropriate MCP tools, and your documentation stays perfectly in sync with your analysis. And here's the best part: when someone asks you to tweak a parameter—say, filter for outages after 2010 or focus on a single region—you just re-run the conversation and the entire repository updates: code, figures, narrative, and README.</div>
<h4 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;">Tips for best results</h4>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">A few lessons learned from using this workflow:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">
<ul style="margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;">
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Use the plain-text format</span> (R2025a+): Set it as your default in Settings → MATLAB → Editor/Debugger → Live script format → M. This makes AI generation much more reliable.</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Set</span> <span style="font-weight: bold; font-family: monospace;">.mlx</span> <span style="font-weight: bold;">as binary in</span> <span style="font-weight: bold; font-family: monospace;">.gitattributes</span> if you're also tracking the binary format: <em>*.mlx binary</em></li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Add an "Open in MATLAB Online" badge</span>: Help others run your analysis instantly:
<pre><span style="white-space: pre;">[![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)]
(https://matlab.mathworks.com/open/github/v1?repo=USERNAME/REPONAME)</span></pre>
</li>
</ul>
</div>
</div>
<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-style: italic;">Special thanks to Rohan Amarapurkar for contributing to this post and for his work making Live Scripts AI-friendly.</span></div>
</div>
<script type="text/javascript">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }</script>]]></content:encoded>
					
					<wfw:commentRss>https://blogs.mathworks.com/deep-learning/2026/02/09/automate-the-documentation-of-your-matlab-analysis-with-agentic-ai/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Building an Optimization Agent with MATLAB MCP Core Server</title>
		<link>https://blogs.mathworks.com/deep-learning/2026/01/26/optimization-agent/?s_tid=feedtopost</link>
					<comments>https://blogs.mathworks.com/deep-learning/2026/01/26/optimization-agent/#respond</comments>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Mon, 26 Jan 2026 20:00:26 +0000</pubDate>
				<category><![CDATA[Agentic AI]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19058</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2026/01/cantilever_beam_optimization2.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>






Co-author: Tom Couture

Tom Couture is the Product Manager for Optimization. In this blog post, he joins me to demonstrates how to use the new MATLAB MCP Core Server to build... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2026/01/26/optimization-agent/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">
<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="alignnone wp-image-19060" src="https://blogs.mathworks.com/deep-learning/files/2025/12/tom.jpg" alt="" width="100" height="100" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Co-author: <a href="https://www.linkedin.com/in/tom-couture-4b756996//" target="_blank" rel="nofollow noopener noreferrer">Tom Couture</a></strong>
<h6></h6>
Tom Couture is the Product Manager for Optimization. In this blog post, he joins me to demonstrates how to use the new MATLAB MCP Core Server to build optimization agents.</td>
</tr>
</tbody>
</table>
<h6><span style="font-size: 14px; font-weight: 400;">If you are like Tom, you have probably spent hours setting up optimization problems in MATLAB—defining objective functions, constraints, choosing solvers, tweaking options. Now, what if I told you that you can have a conversation with an AI agent that does all of this for you, like a mini Tom in your pocket, while </span><span style="font-style: italic;">actually running</span><span style="font-size: 14px; font-weight: 400;"> the optimization in your local MATLAB?</span></h6>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">That is where the <span style="font-weight: bold;">MATLAB MCP Core Server</span> comes in, combined with the powerful <span style="font-weight: bold;">Optimization Toolbox<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span>. In this post, we are going to walk you through how to create an optimization agent that can solve real engineering problems—from simple constrained optimization to computationally expensive CFD-based design optimization using surrogate models.</div>
<h6></h6>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">The First Thing Your Agent Should Do: Check the Toolboxes</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">One of the first features of the MATLAB MCP Core Server I demo is the <span style="font-family: monospace;">detect_matlab_toolboxes</span> tool. Before your agent starts writing optimization code, it should verify that you have the necessary toolboxes installed.</div>
</div>
<h6></h6>
<img decoding="async" loading="lazy" class="aligncenter wp-image-19149" src="https://blogs.mathworks.com/deep-learning/files/2026/01/optim-agent-toolboxes.png" alt="" width="600" height="315" />
<div></div>
<h6></h6>
<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here is a sample prompt to your AI assistant (Claude Desktop®, GitHub Copilot®, or any MCP-compatible client):</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;">"Check which MATLAB toolboxes I have installed, specifically looking for Optimization Toolbox and Global Optimization Toolbox."</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The agent will call the <span style="font-family: monospace;">detect_matlab_toolboxes</span> tool and return something like:</div>
<div class="preformatted-plain" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">Optimization Toolbox - Version 25.2 (R2025b) ✓</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">Global Optimization Toolbox - Version 25.2 (R2025b) ✓</span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This is crucial because the solver you can use depends entirely on what you have licensed. No Optimization Toolbox? The agent will know to fall back to <span style="font-family: monospace;">fminsearch</span>. Have Global Optimization Toolbox? Great, <span style="font-family: monospace;">surrogateopt</span> is on the table for those expensive simulations.</div>
</div>
<h6></h6>
<h6></h6>
<div class="rtcContent">
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Example 1: Structural Beam Design Optimization</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Let me demo to you a classic engineering optimization problem: designing a cantilever beam for minimum weight while satisfying stress and deflection constraints.</div>
<h6></h6>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">The Problem</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">We want to minimize the weight of a rectangular cross-section beam subject to:</div>
<ul style="margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;">
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;">Maximum stress constraint (must not exceed yield strength)</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;">Maximum deflection constraint (must not exceed allowable deflection)</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;">Bounds on width and height</li>
</ul>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here is the prompt I gave to Claude Code:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;">"I need to optimize a cantilever beam design. The beam has length L=5m, carries a tip load P=10kN, made of steel with E=200 GPa and yield stress=250 MPa. I want to minimize the cross-sectional area (width × height) while keeping tip deflection under 10mm and max stress under the yield stress. Width should be between 50-200mm, height between 100-500mm. Please set this up and solve it using MATLAB."</span></div>
<h6></h6>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The agent generated and ran the following code:</div>
<div style="background-color: #f5f5f5; margin: 10px 15px 10px 0; display: inline-block; min-width: 100%;">
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0.666667px solid #d9d9d9; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="color: #008013; white-space-collapse: preserve;">% Beam optimization problem</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">L = 5; <span style="color: #008013;">% Length [m]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">P = 10000; <span style="color: #008013;">% Tip load [N]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">E = 200e9; <span style="color: #008013;">% Young's modulus [Pa]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">sigma_yield = 250e6; <span style="color: #008013;">% Yield stress [Pa]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">delta_max = 0.010; <span style="color: #008013;">% Max deflection [m]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Objective: minimize cross-sectional area</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">objective = @(x) x(1) * x(2); <span style="color: #008013;">% width * height</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Nonlinear constraints</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">nonlcon = @(x) beamConstraints(x, L, P, E, sigma_yield, delta_max);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Bounds: [width_min, height_min] to [width_max, height_max]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">lb = [0.05, 0.10]; <span style="color: #008013;">% [m]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">ub = [0.20, 0.50]; <span style="color: #008013;">% [m]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Initial guess</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">x0 = [0.10, 0.25];</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Solve</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">options = optimoptions(<span style="color: #a709f5;">'fmincon'</span>, <span style="color: #a709f5;">'Display'</span>, <span style="color: #a709f5;">'iter'</span>, <span style="color: #a709f5;">'Algorithm'</span>, <span style="color: #a709f5;">'sqp'</span>);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">[x_opt, fval, exitflag] = fmincon(objective, x0, [], [], [], [], lb, ub, nonlcon, options);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">fprintf(<span style="color: #a709f5;">'Optimal width: %.1f mm\n'</span>, x_opt(1)*1000);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">fprintf(<span style="color: #a709f5;">'Optimal height: %.1f mm\n'</span>, x_opt(2)*1000);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">fprintf(<span style="color: #a709f5;">'Optimal area: %.2f cm²\n'</span>, fval*1e4);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0.666667px solid #d9d9d9; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The constraint function:</div>
<div style="background-color: #f5f5f5; margin: 10px 15px 10px 0; display: inline-block; min-width: 100%;">
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0.666667px solid #d9d9d9; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #0e00ff;">function </span>[c, ceq] = beamConstraints(x, L, P, E, sigma_yield, delta_max)</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> b = x(1); <span style="color: #008013;">% width</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> h = x(2); <span style="color: #008013;">% height</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> I = b * h^3 / 12; <span style="color: #008013;">% Second moment of area</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> sigma = P * L * (h/2) / I; <span style="color: #008013;">% Max bending stress</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> delta = P * L^3 / (3 * E * I); <span style="color: #008013;">% Tip deflection</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> c(1) = sigma - sigma_yield; <span style="color: #008013;">% Stress constraint</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> c(2) = delta - delta_max; <span style="color: #008013;">% Deflection constraint</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> ceq = [];</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #0e00ff;">end</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0.666667px solid #d9d9d9; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The result? An optimal beam with width 80.2mm and height 189.4mm—satisfying both constraints at the boundary, which is exactly what you would expect from a well-posed optimization problem.</div>
</div>
<h6></h6>
<div><img decoding="async" loading="lazy" class="aligncenter wp-image-19160" src="https://blogs.mathworks.com/deep-learning/files/2026/01/cantilever_beam_optimization2.png" alt="" width="800" height="470" /></div>
<div></div>
<h6></h6>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">You can take a look at my conversation with Claude to see some of the rationale as to why he used a <a href="https://www.mathworks.com/help/optim/ug/fmincon.html">fmincon</a> solver for this problem:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><a href="https://mathworks.github.io/MATLAB-AI-Blog/optimization-agent/claude/" target="_blank" rel="noopener">https://mathworks.github.io/MATLAB-AI-Blog/optimization-agent/claude/</a></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">In the repo, I'm also sharing a "skill" for a <a href="https://www.mathworks.com/help/optim/problem-based-approach.html">problem-based approach</a>:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><a href="https://github.com/mathworks/MATLAB-AI-Blog/blob/main/optimization-agent/.claude/skills/problem-based-optim/SKILL.md" target="_blank" rel="noopener">https://github.com/mathworks/MATLAB-AI-Blog/blob/main/optimization-agent/.claude/skills/problem-based-optim/SKILL.md</a></div>
&nbsp;
<div class="rtcContent">
<h6></h6>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Example 2: CFD-Based Optimization with Response Surfaces</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Now let's get to the fun part. One of my favorite applications of optimization in MATLAB is when you have a computationally expensive simulation—like CFD—and you need to find optimal design parameters.</div>
<h6></h6>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">The Lid-Driven Cavity Problem</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The lid-driven cavity is the "Hello World" of CFD. It is a square cavity where the top wall (the "lid") moves at a constant velocity, and you solve the Navier-Stokes equations to find the flow field. For this demo, I will be using an implementation from this problem in pure MATLAB from my colleague Michio in Japan. The code can be found on GitHub: <a href="https://github.com/mathworks/2D-Lid-Driven-Cavity-Flow-Incompressible-Navier-Stokes-Solver" target="_blank" rel="noopener">2D Lid-Driven Cavity Flow Solver</a></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The question I posed to the agent:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;">"I have a CFD solver in the folder 2D-Lid-Driven-Cavity-Flow-Incompressible-Navier-Stokes-Solver. I want to
optimize the lid velocity and Reynolds number to minimize the maximum vorticity in the secondary corner vortex of
a lid-driven cavity flow. Reynolds number should be between 100 and 1000, and lid velocity between 0.5 and 2.0
m/s."</span></div>
<h6></h6>
<h3 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Why Surrogate Optimization?</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">If you have tried running <span style="font-family: monospace;">fmincon</span> on a CFD objective function, you know the pain. Each function evaluation takes 30 seconds, and gradient-based methods might need hundreds of evaluations. <span style="font-family: monospace;">surrogateopt</span> from the Global Optimization Toolbox is designed exactly for this scenario:</div>
<table style="margin: 3px; border: 0.666667px solid #bfbfbf; border-collapse: collapse;">
<tbody>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">What's New</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Why It Matters</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Builds a surrogate (response surface) of your expensive function</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Fewer actual CFD simulations needed</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Uses Radial Basis Function interpolation</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Accurately approximates complex surfaces</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Global search capability</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Doesn't get stuck in local minima</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Supports parallel evaluation</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Use all your CPU cores</div></td>
</tr>
</tbody>
</table>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here is the code the agent generated:</div>
<div style="background-color: #f5f5f5; margin: 10px 15px 10px 0; display: inline-block; min-width: 100%;">
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0.666667px solid #d9d9d9; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Define bounds</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">lb = [100, 0.5]; <span style="color: #008013;">% [Re_min, V_min]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">ub = [1000, 2.0]; <span style="color: #008013;">% [Re_max, V_max]</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Set up surrogate optimization</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">options = optimoptions(<span style="color: #a709f5;">'surrogateopt'</span>, <span style="color: #0e00ff;">...</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #a709f5;">'Display'</span>, <span style="color: #a709f5;">'iter'</span>, <span style="color: #0e00ff;">...</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #a709f5;">'PlotFcn'</span>, <span style="color: #a709f5;">'surrogateoptplot'</span>, <span style="color: #0e00ff;">...</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #a709f5;">'MaxFunctionEvaluations'</span>, 50, <span style="color: #0e00ff;">...</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #a709f5;">'MinSurrogatePoints'</span>, 20);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Run optimization</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">[x_opt, fval, exitflag, output] = surrogateopt(@cavityObjective, lb, ub, options);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">fprintf(<span style="color: #a709f5;">'Optimal Reynolds number: %.0f\n'</span>, x_opt(1));</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">fprintf(<span style="color: #a709f5;">'Optimal lid velocity: %.2f m/s\n'</span>, x_opt(2));</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;">fprintf(<span style="color: #a709f5;">'Minimum corner vorticity: %.4f\n'</span>, fval);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0.666667px solid #d9d9d9; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The objective function:</div>
<div style="background-color: #f5f5f5; margin: 10px 15px 10px 0; display: inline-block; min-width: 100%;">
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0.666667px solid #d9d9d9; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #0e00ff;">function </span>obj = cavityObjective(x)</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> Re = x(1);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> V_lid = x(2);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Run CFD simulation (using 2D-Lid-Driven-Cavity solver)</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> [u, v] = runCavitySimulation(Re, V_lid);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Calculate vorticity in corner region</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> [vorticity] = calculateVorticity(u, v);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #008013;">% Extract max vorticity in secondary vortex region</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> cornerRegion = vorticity(1:20, 1:20);</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"> obj = max(abs(cornerRegion(:)));</span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"><span style="white-space: pre;"><span style="color: #0e00ff;">end</span></span></div>
</div>
<div class="inlineWrapper">
<div style="border-left: 0.666667px solid #d9d9d9; border-right: 0.666667px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0.666667px solid #d9d9d9; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;"></div>
</div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The beauty of <span style="font-family: monospace;">surrogateopt</span> is that it builds a response surface as it goes. After just 20 function evaluations (about 5 minutes), it found the optimal operating point—something that would have taken hours with a grid search.</div>
</div>
<h6></h6>
<img decoding="async" loading="lazy" class="aligncenter wp-image-19162" src="https://blogs.mathworks.com/deep-learning/files/2026/01/Surrogate-Optimization-Result.png" alt="" width="800" height="298" />

&nbsp;
<div class="rtcContent">
<h6></h6>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">What's Next?</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The combination of MATLAB MCP Core Server + Optimization Toolbox opens up a whole new way of doing engineering optimization. Instead of context-switching between documentation, code editor, and command window, you can have a conversation with an AI that:</div>
<ol style="margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;">
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Checks your toolboxes</span> to know what solvers are available</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Formulates the problem</span> based on your natural language description</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Writes and runs the code</span> in your local MATLAB</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Iterates on errors</span> without you copying and pasting</li>
</ol>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">If you want to try this yourself, head over to the <a href="https://github.com/matlab/matlab-mcp-core-server" target="_blank" rel="noopener">MATLAB MCP Core Server repository</a> and follow the setup instructions. The server provides five core tools—but combined with the 100+ functions in Optimization Toolbox, the possibilities are endless.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Happy optimizing! <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f501.png" alt="🔁" class="wp-smiley" style="height: 1em; max-height: 1em;" /></div>
<h6></h6>
<h2 style="margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">See Also</h2>
<ul style="margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px;">
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><a href="https://blogs.mathworks.com/deep-learning/2025/11/03/releasing-the-matlab-mcp-core-server-on-github/">Releasing the MATLAB MCP Core Server on GitHub</a></li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><a href="https://www.mathworks.com/help/gads/surrogate-optimization.html">Surrogate Optimization Documentation</a></li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><a href="https://github.com/mathworks/2D-Lid-Driven-Cavity-Flow-Incompressible-Navier-Stokes-Solver" target="_blank" rel="noopener">2D Lid-Driven Cavity Flow Solver</a></li>
</ul>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-style: italic;">Special thanks to Michio Inoue for the cavity flow solver.</span></div>
</div>
<script type="text/javascript">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }</script>]]></content:encoded>
					
					<wfw:commentRss>https://blogs.mathworks.com/deep-learning/2026/01/26/optimization-agent/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Giving Local AI Agents the ability to use MATLAB with MCP</title>
		<link>https://blogs.mathworks.com/deep-learning/2026/01/21/giving-local-ai-agents-the-ability-to-use-matlab-with-mcp/?s_tid=feedtopost</link>
					<comments>https://blogs.mathworks.com/deep-learning/2026/01/21/giving-local-ai-agents-the-ability-to-use-matlab-with-mcp/#respond</comments>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Wed, 21 Jan 2026 15:26:20 +0000</pubDate>
				<category><![CDATA[Agentic AI]]></category>
		<category><![CDATA[Local AI]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19125</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2026/01/article_2.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>








Guest writer: Abhijit Bhattacharjee

Abhijit is an application engineer at MathWorks and an expert in AI. He supports customers with the latest and greatest technologies in the... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2026/01/21/giving-local-ai-agents-the-ability-to-use-matlab-with-mcp/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<div class="rtcContent">
<div>
<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">
<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="alignnone wp-image-19126" src="https://blogs.mathworks.com/deep-learning/files/2026/01/abhijit_small.jpg" alt="" width="100" height="100" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Guest writer: </strong><a href="https://www.linkedin.com/in/bhattacharjeeabhijit">Abhijit Bhattacharjee</a>

Abhijit is an application engineer at MathWorks and an expert in AI. He supports customers with the latest and greatest technologies in the space, specifically Agentic AI in the past couple of months.</td>
</tr>
</tbody>
</table>
</div>
</div>
<h6></h6>
<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
</div>
</div>
<div></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Building on my colleague <a href="https://www.mathworks.com/matlabcentral/profile/authors/20789457?s_tid=blg_to_profile">Mike's</a> fabulous article on <a href="https://blogs.mathworks.com/matlab/2026/01/05/running-large-language-models-on-the-nvidia-dgx-spark-and-connecting-to-them-in-matlab/">running LLMs on the NVIDIA DGX Spark and connecting to them in MATLAB</a>, I wanted to see if I could flip the workflow; instead of MATLAB calling an LLM (Large Language Model), what if I could have a <span style="font-weight: bold;">local LLM agent call MATLAB?</span> That way, the entire MATLAB itself becomes a tool at the agent's disposal, ready to perform, execute, and verify code that the LLM writes.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">And the best part? Nothing leaves my network and it's all handled locally.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Fortunately for me, I was also able to get my hands on a beautiful NVIDIA DGX Spark unit to play around with.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 754px; height: 425px;" src="https://blogs.mathworks.com/deep-learning/files/2026/01/article_1.png" alt="" width="754" height="425" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">You can learn more about the DGX Spark's specs <a href="https://www.nvidia.com/en-us/products/workstations/dgx-spark/">HERE</a>, but the key thing here is that it has enough VRAM (128GB) to handle local LLMs of significant enough size that they can do real engineering work. And that's what I'd like to share with you today.</div>
<h2 style="margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Setting up the local LLM</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Like Mike, I chose to use the fantastic <a href="https://openai.com/index/introducing-gpt-oss/">gpt-oss-120b</a> model for its reliable tool-calling abilities and its high performance as a <a href="https://en.wikipedia.org/wiki/Mixture_of_experts">mixture-of-experts (MoE)</a>, which means it only uses a fraction of 120 billion parameters actively, reducing the computational load. However, I chose a slightly more complex route than he did, and decided to compile <a href="https://github.com/ggml-org/llama.cpp">llama.cpp</a> from source to run the model, to try and eke out even more tokens-per-second (tps) than Ollama, which also uses llama.cpp as its backend. While this sounds intimidating, it's actually not so bad, especially with the comprehensive instructions in the repository.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">To make use of the local model, you need to launch llama-server with the right parameters. Here is my optimized launch command for the DGX Spark to run gpt-oss-120b:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;">llama-server \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> -m models/gpt-oss-120b/Q4_K_M/gpt-oss-120b-Q4_K_M-00001-of-00002.gguf \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --host 0.0.0.0 --port 8080 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> -ngl 999 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> -fa on \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> -t 10 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> -c 0 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> -b 2048 -ub 2048 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> -ctk q8_0 -ctv q8_0 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --no-mmap \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --jinja \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --reasoning-format auto \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --chat-template-kwargs "{\"reasoning_effort\": \"medium\"}" \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --temp 1.0 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --top-p 1.0 \</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> --top-k 0</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Running it in this way allowed me to specify some optimizations, such as <span style="font-family: monospace;">--no-mmap</span>, which disables memory-mapped file I/O (not needed for unified memory architectures such as the DGX Spark) and <span style="font-family: monospace;">-fa on</span>, which enables flash attention kernels, speeding up processing of long sequences of tokens.</div>
<h3 style="margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Agentic AI coding with the local model</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Now before we get to using MATLAB as a callable tool, I needed a way to interact with this local model outside of MATLAB. Fortunately, we can use the very popular agentic AI terminal application <a href="https://opencode.ai/">OpenCode</a> as a harness. OpenCode allows you to configure a local model in a number of ways. One easy way is to use the opencode.json configuration file.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The other thing I want to do is point OpenCode at the local <a href="https://github.com/matlab/matlab-mcp-core-server">MATLAB MCP Core Server</a> instance on my machine. To catch up on Model Context Protocol (MCP) and how it works, definitely check out one of our recent blog posts on the topic, like <a href="https://blogs.mathworks.com/deep-learning/2025/11/03/releasing-the-matlab-mcp-core-server-on-github/">THIS ONE</a>.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">A bit more JSON finagling, and our full opencode.json file to configure both the local LLM (with an endpoint address of <span style="font-family: monospace;">192.168.108.170</span>) and the local MATLAB MCP connection looks as follows.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;">{</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "$schema"</span><span style="font-family: monospace;">: </span><span style="font-family: monospace;">"https://opencode.ai/config.json"</span><span style="font-family: monospace;">,</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "provider"</span><span style="font-family: monospace;">: {</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "llama.cpp"</span><span style="font-family: monospace;">: {</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "npm"</span><span style="font-family: monospace;">: </span><span style="font-family: monospace;">"@ai-sdk/openai-compatible"</span><span style="font-family: monospace;">,</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "name"</span><span style="font-family: monospace;">: </span><span style="font-family: monospace;">"llama.cpp (abhijit-spark)"</span><span style="font-family: monospace;">,</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "options"</span><span style="font-family: monospace;">: {</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "baseURL"</span><span style="font-family: monospace;">: </span><span style="font-family: monospace;">"http://192.168.108.170:8080/v1"</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> },</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "models"</span><span style="font-family: monospace;">: {</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "gpt-oss-120b-GGUF"</span><span style="font-family: monospace;">: {</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "name"</span><span style="font-family: monospace;">: </span><span style="font-family: monospace;">"gpt-oss-120b"</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> }</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> }</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> }</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> },</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "mcp"</span><span style="font-family: monospace;">: {</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "MATLAB MCP"</span><span style="font-family: monospace;">: {</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "type"</span><span style="font-family: monospace;">: </span><span style="font-family: monospace;">"local"</span><span style="font-family: monospace;">,</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "command"</span><span style="font-family: monospace;">: [</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "C:</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">Users</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">abhijit</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">Local Content</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">Apps</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">matlab-mcp-core-server-win64.exe"</span><span style="font-family: monospace;">, </span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "--matlab-root=C:</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">Program Files</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">MATLAB</span><span style="font-family: monospace;">\\</span><span style="font-family: monospace;">R2025b"</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> ],</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> "enabled"</span><span style="font-family: monospace;">: </span><span style="font-family: monospace;">true</span><span style="font-family: monospace;">,</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> }</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;"> }</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-family: monospace;">}</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">After configuring everything as above, when I launch OpenCode, I'm greeted with a screen showing me that both the local model is selected and available, and that the MATLAB MCP is connected and running:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="imageNode" style="vertical-align: baseline; width: 769px; height: 377px;" src="https://blogs.mathworks.com/deep-learning/files/2026/01/article_2.png" alt="" width="769" height="377" /></div>
<h2 style="margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;">Let's start vibe coding!</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">To show off how well this works with the MATLAB MCP Core Server enabled, I'm going to enter the following prompt, which will do some data analysis on a built-in dataset that comes installed with MATLAB:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-style: italic;">Create a MATLAB script that loads carbig dataset and creates 3 plots showcasing how different car properties affect MPG. Use default positions for any figures you create. </span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-style: italic;">Train an ensemble regression model using this data to predict MPG from weight, horsepower, displacement, and acceleration. Show me the model statistics and diagnostic plots.</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-style: italic;">Use the MATLAB MCP to execute and test your code.</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Now normally, with frontier models such as Claude Opus or GPT-5.2, you don't need to specify that the MCP needs to be invoked. Those LLMs will figure it out automatically. But for gpt-oss-120b, I decided it to give that extra bit of guidance, just so it wouldn't spin its wheels for too long. Here's a video demonstration of my coding session.</div>
<div class="row"><div class="col-xs-12 containing-block"><div class="bc-outer-container add_margin_20"><videoplayer><div class="video-js-container"><video data-video-id="6387829030112" data-video-category="blog" data-autostart="false" data-account="62009828001" data-omniture-account="mathwgbl" data-player="rJ9XCz2Sx" data-embed="default" id="mathworks-brightcove-player" class="video-js" controls></video><script src="//players.brightcove.net/62009828001/rJ9XCz2Sx_default/index.min.js"></script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs("mathworks-brightcove-player").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();</script></div></videoplayer></div></div></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">So that's the magic: a local LLM agent driving MATLAB like a pro, with everything running on your own hardware and none of your data drifting off into the cloud. The DGX Spark has more than enough muscle to make models like gpt-oss-120b genuinely useful, and once you plug it into the MATLAB MCP Core Server, the whole setup feels surprisingly natural, almost like MATLAB just became another tool in your AI's toolbox.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Is it perfect? Not yet. But it's already <span style="font-style: italic;">good</span>, and with a little prompt tuning (or a beefier model like <a href="https://mistral.ai/news/devstral-2-vibe-cli">Devstral 2</a>), it gets even better.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This workflow shows what's coming: real engineering work powered by local AI agents, fully private, fully under your control, and honestly...pretty fun to use.</div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://blogs.mathworks.com/deep-learning/2026/01/21/giving-local-ai-agents-the-ability-to-use-matlab-with-mcp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Reinforcement Learning on Hardware, explained by Brian Douglas</title>
		<link>https://blogs.mathworks.com/deep-learning/2026/01/13/reinforcement-learning-on-hardware-explained-by-brian-douglas/?s_tid=feedtopost</link>
					<comments>https://blogs.mathworks.com/deep-learning/2026/01/13/reinforcement-learning-on-hardware-explained-by-brian-douglas/#respond</comments>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Tue, 13 Jan 2026 15:00:49 +0000</pubDate>
				<category><![CDATA[Embedded AI]]></category>
		<category><![CDATA[Reinforcement Learning]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19069</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2025/12/rl-hardware-brian-douglas_2.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>






Co-author: Brian Douglas

Brian is a Technical Content Creator at MathWorks and control engineer with over 20 years of experience in the field, and a passion for sharing his knowledge... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2026/01/13/reinforcement-learning-on-hardware-explained-by-brian-douglas/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">
<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19070" src="https://blogs.mathworks.com/deep-learning/files/2025/12/brian-150x150.jpg" alt="" width="100" height="100" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Co-author: <a href="https://www.linkedin.com/in/brian-douglas-505b7175/" target="_blank" rel="nofollow noopener noreferrer">Brian Douglas</a></strong>

Brian is a Technical Content Creator at MathWorks and control engineer with over 20 years of experience in the field, and a passion for sharing his knowledge with others. He creates and posts engaging videos, drawings, and short writings on various engineering topics. You can find his Tech Talks series on mathworks.com and YouTube.</td>
</tr>
</tbody>
</table>
</div>
</div>
<h6></h6>
<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">You've probably seen impressive demos of reinforcement learning agents doing amazing things—balancing poles, playing games, controlling robots. But here's the thing: getting from "cool simulation" to "actually running on hardware" is where it gets tricky.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">My colleague Brian Douglas just released a Tech Talk that tackles exactly this question. Not the specifics of RL algorithms (<a href="https://www.mathworks.com/videos/reinforcement-learning-part-1-what-is-reinforcement-learning-1551974943006.html">we have a whole series for that</a>), but something that doesn't get nearly enough attention: <span style="font-style: italic;">which approach should you take</span> to get a good policy running on your hardware?</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">I know that doesn't sound terribly exciting at first. But trust me—it matters a lot for hardware safety and how long you'll spend waiting for your policy to converge.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<h3 style="margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">The setup</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Brian demonstrates this with a <a href="https://www.quanser.com/products/qube-servo-2/" target="_blank" rel="noopener">Quanser® Qube-Servo 2</a> rotary pendulum, controlled by a policy running on a Raspberry Pi®, which is connected to a PC running MATLAB® and Simulink®. Three pieces of hardware working together—and how you use them depends entirely on your approach to training.</div>
<h6></h6>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">If you want to follow along with your own hardware, check out the <a href="https://github.com/mathworks/Reinforcement-Learning-Inverted-Pendulum-with-QUBE-Servo2" data-href="https://github.com/mathworks/Reinforcement-Learning-Inverted-Pendulum-with-QUBE-Servo2">GitHub example</a> that covers the complete workflow from plant modeling to deployment.</div>
</div>
<h6></h6>
&nbsp;
<h6></h6>
<div class="rtcContent">
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19088" src="https://blogs.mathworks.com/deep-learning/files/2025/12/3-hardware.png" alt="" width="800" height="450" /></div>
<h3 style="margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">The decision flowchart</h3>
<h6></h6>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here is the complete decision tree that Brian covers in his video. Let's break it down, step by step:</div>
<h6></h6>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19067" src="https://blogs.mathworks.com/deep-learning/files/2025/12/rl-hardware-brian-douglas_3.png" alt="" width="800" height="450" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Let me walk you through the key decision points:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">1. Do you have existing data?</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">You can learn a policy offline from data collected by humans or another controller. This is great for bootstrapping—getting a decent starting point before you do any online training.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">2. Where do you get additional data?</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This is the big fork in the road: train directly on hardware (real environment) or train in simulation (modeled environment). Both have trade-offs. Brian covers the <a href="https://www.mathworks.com/videos/reinforcement-learning-part-2-understanding-the-environment-and-rewards-1551976590603.html">environment setup</a> in detail in Part 2 of the RL series.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<h3 style="margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Training directly on hardware</h3>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;"> Where does inference happen vs. where does learning happen?</span></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">This one's subtle but important. You might have a low-power embedded processor (like a Raspberry Pi) and a more powerful PC or cloud server. You can mix and match:</div>
<table style="margin: 3px; border: 0.666667px solid #bfbfbf; border-collapse: collapse;">
<tbody>
<tr style="background-color: #f5f5f5;">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Approach</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Pros</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Cons</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Train &amp; run on embedded</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Self-contained, minimal latency</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Embedded processor may be too weak for training</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Train &amp; run on remote PC</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Faster learning</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Susceptible to latency and connection issues</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Train on PC, run on embedded</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Best of both worlds</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">More complex setup</div></td>
</tr>
</tbody>
</table>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Brian goes with that third option—and honestly, it's often the sweet spot for real hardware applications.</div>
<div class="rtcContent">
<div></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The results? Well...</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The first episodes are rough. Random commands, motor jittering, the pendulum occasionally banging into the power cord (which let's admit, isn't great for the hardware). After several hours and almost 1,500 episodes, the policy could balance the pendulum—but with noticeable wobble and plenty of room for improvement.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">The takeaway: training on hardware is straightforward but time-consuming, potentially dangerous, and hard to cover all operating states your system might encounter in the real world.</div>
<h3 style="margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Training in simulation</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Here's where things get more practical. With a model of your environment, you can:
- Train faster than real-time
- Forget about hardware safety during exploration
- Easily test different initial conditions and scenarios</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Brian trained against a simulated Qube model for about 1,200 episodes. The result? A policy that controls the pendulum rock-steady in simulation—reward over 800, nice and settled.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">But the real question: does it work on actual hardware?</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">For a detailed answer with code, see this example from the documentation: <a href="https://www.mathworks.com/help/reinforcement-learning/ug/train-agents-to-control-quanser-qube-pendulum.html">Train Reinforcement Learning Agents to Control Quanser QUBE Pendulum</a></div>
<h3 style="margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">The sim2real gap</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">When Brian deployed the simulation-trained policy to the real Qube, it worked pretty well! No terrible jittering, no banging into cables. But if you look closely, there's a small amount of wobble that wasn't there in simulation.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">That's the sim2real gap—the difference between what your model predicts and what happens in reality. Now, this isn't necessarily a problem. Models don't have to be perfect; they just have to be useful. If the behavior meets your requirements, you're done.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">But if it's not good enough, you have options:</div>
<div><strong> 1. Improve the model</strong> — Add more dynamics, use domain randomization to make your policy more robust</div>
<div> <strong>2. Fine-tune on hardware</strong> — Start from your simulation-trained policy and continue learning on the real system</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">That second approach is particularly nice because you're not starting from scratch. Your policy already knows roughly what to do, so training is faster and puts less stress on the hardware.</div>
<div></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<h3 style="margin: 15px 10px 5px 4px; padding: 0px; line-height: 20.4px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;">Why this matters</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">There's no single best way to learn a policy for hardware. It depends on how well you can model your environment, how hard it is to reset between episodes, and how much you care about hardware safety (spoiler: probably a lot).</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">But this workflow—train in simulation, fine-tune on hardware, run policy on embedded processor, learn on a remote computer—is actually ideal for many situations. It's also the foundation for continuous learning, where your policy keeps adapting as components wear out or conditions change, without requiring a full retraining cycle.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Brian goes into much more detail in the video, including live demos of all three approaches and the actual Simulink models involved. Highly recommend watching the full thing:</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f4fd.png" alt="📽" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://www.mathworks.com/videos/reinforcement-learning-on-hardware-1765346150358.html">Reinforcement Learning on Hardware</a></div>
<div class="row"><div class="col-xs-12 containing-block"><div class="bc-outer-container add_margin_20"><videoplayer><div class="video-js-container"><video data-video-id="6386267250112" data-video-category="blog" data-autostart="false" data-account="62009828001" data-omniture-account="mathwgbl" data-player="rJ9XCz2Sx" data-embed="default" id="mathworks-brightcove-player" class="video-js" controls></video><script src="//players.brightcove.net/62009828001/rJ9XCz2Sx_default/index.min.js"></script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs("mathworks-brightcove-player").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();</script></div></videoplayer></div></div></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">And if you're new to reinforcement learning, check out Brian's multi-part <a href="https://www.mathworks.com/videos/reinforcement-learning-part-1-what-is-reinforcement-learning-1551974943006.html">Tech Talk series</a> that covers the fundamentals.</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Happy reinforcement learning! <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f916.png" alt="🤖" class="wp-smiley" style="height: 1em; max-height: 1em;" /></div>
</div>
<script type="text/javascript">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }</script>]]></content:encoded>
					
					<wfw:commentRss>https://blogs.mathworks.com/deep-learning/2026/01/13/reinforcement-learning-on-hardware-explained-by-brian-douglas/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Antigravity + MATLAB is wicked good</title>
		<link>https://blogs.mathworks.com/deep-learning/2025/12/24/antigravity-plus-matlab-is-wicked-good/?s_tid=feedtopost</link>
					<comments>https://blogs.mathworks.com/deep-learning/2025/12/24/antigravity-plus-matlab-is-wicked-good/#comments</comments>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Wed, 24 Dec 2025 16:30:42 +0000</pubDate>
				<category><![CDATA[Agentic AI]]></category>
		<category><![CDATA[Agentic App Building]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19003</guid>

					<description><![CDATA[<div class="overview-image"><img  class="img-responsive" src="https://blogs.mathworks.com/deep-learning/files/2025/12/antigravityMatlabMcpBlog_1.png" onError="this.style.display ='none';" /></div><p>
Google released a new agentic development environment called Antigravity. And it works great with MATLAB. (It's wicked as they say in Boston!)

If you are looking to defy gravity, here is a fun... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2025/12/24/antigravity-plus-matlab-is-wicked-good/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<h6></h6>
Google released a new agentic development environment called <strong>Antigravity</strong>. And it works great with MATLAB. (It's wicked as they say in Boston!)
<h6></h6>
If you are looking to defy gravity, here is a fun use case for an app leveraging the power of MATLAB and Antigravity:
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<h6 style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></h6>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19093" src="https://blogs.mathworks.com/deep-learning/files/2025/12/antigravityMatlabMcpBlog_1.png" alt="" width="800" height="420" /></div>
<h6></h6>
<h6></h6>
&nbsp;
<h6></h6>
<h6></h6>
This article will look at three different components, that were built using Antigravity + MATLAB:

&nbsp;
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<table style="margin: 3px; border: 0.666667px solid #bfbfbf; border-collapse: collapse;">
<tbody>
<tr style="background-color: #f5f5f5;">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Component</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Description</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">uihtml + React workflow</span></div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Modern web frameworks embedded seamlessly in MATLAB desktop apps</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">Flight data replay</span></div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Post-process and visualize trajectories with <span style="font-family: monospace;">gravityFlightDashboard</span></div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"><span style="font-weight: bold;">Defying Gravity Toolbox</span></div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">A fully-packaged MATLAB app with 3D graphics powered by Three.js</div></td>
</tr>
</tbody>
</table>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div></div>
<h6></h6>
&nbsp;
<h6></h6>
<h6></h6>
<h2>The AI Copy &amp; Paste Problem (Revisited for apps)</h2>
<h6></h6>
Regular readers will remember the core problem that led us to <a href="https://blogs.mathworks.com/deep-learning/2025/11/03/releasing-the-matlab-mcp-core-server-on-github/">release the MATLAB MCP Core Server</a>: the tedious copy-paste loop between your favorite AI chat and MATLAB. Write code in ChatGPT or Claude, copy it, paste it in MATLAB, get an error, copy the error, paste it back... iterate.
<h6></h6>
The MCP server solved that for MATLAB code. But what about <strong>apps</strong>?
<h6></h6>
Building a MATLAB app with modern 3D graphics used to require deep knowledge of app building in MATLAB, plus OpenGL graphics. Now, with uihtml, you can embed any web technology—React, Three.js, D3.js—directly inside a MATLAB figure. The catch? You need to know web development too.
<h6></h6>
That is where AI agents come in. I described what I wanted in natural language, and Antigravity (with the MATLAB MCP Core Server connected) helped me scaffold the whole thing.
<h6></h6>
&nbsp;
<h6></h6>
<h2>Connect MATLAB to Antigravity</h2>
<h6></h6>
Let's start by connecting MATLAB to Antigravity. There are two steps you can take, quite similar to how you would in VSCode (Antigravity is a fork of VSCode):
<ol>
 	<li>Install the MATLAB extension</li>
 	<li>Set up the MATLAB MCP Core Server</li>
</ol>
&nbsp;
<h6></h6>
Navigate to the extension side-panel, and search for <strong>MATLAB</strong>:
<h6></h6>
<img decoding="async" loading="lazy" class="aligncenter wp-image-19100" src="https://blogs.mathworks.com/deep-learning/files/2025/12/antigravity-matlab-extension.png" alt="" width="800" height="406" />
<h6></h6>
&nbsp;
<h6></h6>
You will find the MCP Server setup screen in the three dots on the top right of the Agent side panel (slightly different from VSCode).
<h6></h6>
<h6></h6>
<img decoding="async" loading="lazy" class="aligncenter wp-image-19097" src="https://blogs.mathworks.com/deep-learning/files/2025/12/antigravity-mcp-server-setup.png" alt="" width="800" height="404" />
<h6></h6>
&nbsp;
<h6></h6>
<h6></h6>
Once your MATLAB is connected to Antigravity, you can ask the following prompt:
<h6></h6>
<blockquote>Generate a MATLAB App with 2 windows:
One web frontend implementing a flight simulator in React and ThreeJS that enables to record the trajectory in a CSV file. This web frontend will be integrated in a MATLAB uihtml component.
The second window is a dashboard post-processing the trajectories with MATLAB plots. There is a button that enables to open the simulator from this view.</blockquote>
<h6></h6>
&nbsp;
<h6></h6>
<h6></h6>
<h2>Testing web frontend before integration in uihtml</h2>
<h6></h6>
MATLAB Apps can integrate HTML UI components through the use of the function <a href="https://www.mathworks.com/help/matlab/ref/uihtml.html">uihtml</a>. One great combo is to use the embedded chrome browser in Antigravity to test the interactions of the web frontend before integrating it into your app:
<h6></h6>
<h6></h6>
<div class="row"><div class="col-xs-12 containing-block"><div class="bc-outer-container add_margin_20"><videoplayer><div class="video-js-container"><video data-video-id="6386913440112" data-video-category="blog" data-autostart="false" data-account="62009828001" data-omniture-account="mathwgbl" data-player="rJ9XCz2Sx" data-embed="default" id="mathworks-brightcove-player" class="video-js" controls></video><script src="//players.brightcove.net/62009828001/rJ9XCz2Sx_default/index.min.js"></script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs("mathworks-brightcove-player").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();</script></div></videoplayer></div></div></div>
<h6></h6>
<h6></h6>
<h6></h6>
<h2>Let's Walk Through the Generated Code</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<h6></h6>
<h6></h6>
<h3>The Main App Entry Point</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
The core of <span style="font-family: monospace;">gravityFlightSimulator.m</span> is surprisingly simple:
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-matlab" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #0e00ff;">function </span>gravityFlightSimulator()</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #008013;">% Create main figure with appropriate size</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> fig = uifigure(<span style="color: #a709f5;">'Name'</span>, <span style="color: #a709f5;">'Defying Gravity'</span>, <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #a709f5;">'Position'</span>, [100 100 1200 800], <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #a709f5;">'Color'</span>, [0 0 0], <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #a709f5;">'AutoResizeChildren'</span>, <span style="color: #a709f5;">'off'</span>);</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #008013;">% Get the path to the HTML file and icon</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> appDir = fileparts(mfilename(<span style="color: #a709f5;">'fullpath'</span>));</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> htmlFile = fullfile(appDir, <span style="color: #a709f5;">'dist'</span>, <span style="color: #a709f5;">'index.html'</span>);</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> iconFile = fullfile(appDir, <span style="color: #a709f5;">'dist'</span>, <span style="color: #a709f5;">'broom.png'</span>);</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #008013;">% Set the app icon (yes, it's a broom)</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> fig.Icon = iconFile;</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #008013;">% Create uihtml component filling the entire figure</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> h = uihtml(fig, <span style="color: #a709f5;">'Position'</span>, [0 0 fig.Position(3) fig.Position(4)]);</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> h.HTMLSource = htmlFile;</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #008013;">% Handle figure resize to keep uihtml fullscreen</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"> fig.SizeChangedFcn = @(src, ~) resizeHTML(src, h);</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #0e00ff;">end</span></span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
That's it. About 20 lines of MATLAB to embed a full 3D flight simulator.
<h6></h6>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<h6></h6>
<h6></h6>
<h3>The Flight Controls</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
The web app (built with React and Three.js) provides the flight physics:
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<table style="margin: 3px; border: 0.666667px solid #bfbfbf; border-collapse: collapse;">
<tbody>
<tr style="background-color: #f5f5f5;">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Control</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Action</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">W/S</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Throttle Up/Down</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Up/Down</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Pitch Up/Down</div></td>
</tr>
<tr style="background-color: rgba(0, 0, 0, 0);">
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Left/Right</div></td>
<td style="border: 0.666667px solid #bfbfbf; vertical-align: top;">
<div style="margin: 2px 10px 2px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: break-spaces; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;">Roll Left/Right</div></td>
</tr>
</tbody>
</table>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
And you can switch between a plane and a witch on a broomstick (hence the icon). Because why not?
<h6 style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></h6>
<div></div>
<h6></h6>
<h6></h6>
<h3>Post-Processing with gravityFlightDashboard</h3>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
The app can export flight data to CSV. Then comes the MATLAB part—analyzing trajectories with <span style="font-family: monospace;">gravityFlightDashboard</span>:
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-matlab" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">gravityFlightDashboard(<span style="color: #a709f5;">'gravity-flight-2025-12-07.csv'</span>)</span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
This opens a replay dashboard with:
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<ul>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">3D trajectory visualization</span> with heading arrows</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Altitude vs. time plot</span></li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Play/Pause/Reset controls</span> with a timeline slider</li>
 	<li style="margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;"><span style="font-weight: bold;">Real-time flight metrics</span>: speed, altitude, pitch, roll</li>
</ul>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-matlab" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #008013;">% The dashboard using MATLAB graphics</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">plot3(pathAxes, position(:,1), position(:,2), position(:,3), <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #a709f5;">'Color'</span>, [0.7 0.7 0.7], <span style="color: #a709f5;">'LineWidth'</span>, 1.25);</span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">craftMarker = plot3(pathAxes, position(1,1), position(1,2), position(1,3), <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #a709f5;">'o'</span>, <span style="color: #a709f5;">'MarkerFaceColor'</span>, [0.95 0.3 0.2], <span style="color: #a709f5;">'MarkerEdgeColor'</span>, <span style="color: #a709f5;">'k'</span>, <span style="color: #0e00ff;">...</span></span></div>
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;"><span style="color: #a709f5;">'MarkerSize'</span>, 8);</span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
This is the beauty of the hybrid approach: use web tech for the interactive 3D simulation, use MATLAB for post-processing and analysis.
<h6></h6>
If you are interested in more advanced flight data analysis, I recommend you take a look at our <a href="https://www.mathworks.com/products/uav.html">UAV toolbox</a>.
<h6></h6>
&nbsp;
<h6></h6>
<h2>Packaging as a Toolbox</h2>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
One of my favorite parts: you can package this as a proper MATLAB toolbox (<span style="font-family: monospace;">.mltbx</span> file) that anyone can install with one click.
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;"><img decoding="async" loading="lazy" width="723" height="535" class="size-full wp-image-19103 aligncenter" src="https://blogs.mathworks.com/deep-learning/files/2025/12/toolbox.png" alt="" /></div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<h6></h6>
&nbsp;
<h6></h6>
The "Gravity" toolbox appears right alongside your other add-ons.
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
Install it like this:
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-matlab" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">matlab.addons.install(<span style="color: #a709f5;">'Gravity.mltbx'</span>)</span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
Then just run:
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
<div class="preformatted-matlab" style="margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;">
<div style="border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;"><span style="white-space: pre;">gravityApp</span></div>
</div>
<div style="margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;"></div>
The toolbox bundles everything: the MATLAB code, the web assets, the broom icon. Users don't need to know anything about React or Three.js—they just install and fly.
<h6></h6>
&nbsp;
<h2>Calling the Wizard of Apps</h2>
For the next post of this series on<strong> Agentic App Building</strong>, I will turn to colleague Pax, who I call the <em>"Wizard of Apps"</em>:
<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="aligncenter wp-image-19004 size-full" src="https://blogs.mathworks.com/deep-learning/files/2025/12/pax.jpg" alt="" width="200" height="200" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Next episode: <a href="https://www.linkedin.com/in/ricardopaxson" target="_blank" rel="nofollow noopener noreferrer">Rick Paxson</a></strong> aka "Pax"
<h6></h6>
<h6></h6>
Rick Paxson is the Director of Computational Biology at MathWorks. He is an experienced programmer and an early adopter of AI assisted coding. I always turned to him for advices on how to best leverage AI in software development.</td>
</tr>
</tbody>
</table>
<h6></h6>
<h6></h6>
He developed some particular <em>"skills"</em> that he shared with <a href="https://blogs.mathworks.com/community/2025/11/04/storyboarding-with-live-script-skills/">Ned</a> and I to build MATLAB Apps with a web front end. If you are too impatient, you can get a sneak peek into the recipe we will use:

<a href="https://github.com/matlab/skills/blob/main/skills/matlab-uihtml-app-builder/SKILL.md">skills/skills/matlab-uihtml-app-builder/SKILL.md</a>
<h6></h6>
In the meantime, I wish you a wicked Christmas<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f385.png" alt="🎅" class="wp-smiley" style="height: 1em; max-height: 1em;" />

&nbsp;
<h6></h6>
<strong>PS:</strong> Check out the code and have fun defying gravity<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f9f9.png" alt="🧹" class="wp-smiley" style="height: 1em; max-height: 1em;" />
<h6></h6>
<a href="https://github.com/mathworks/MATLAB-AI-Blog/tree/main/antigravity-plus-matlab-is-wicked-good">MATLAB-AI-Blog/antigravity-plus-matlab-is-wicked-good at main · mathworks/MATLAB-AI-Blog</a>
<h6></h6>
&nbsp;]]></content:encoded>
					
					<wfw:commentRss>https://blogs.mathworks.com/deep-learning/2025/12/24/antigravity-plus-matlab-is-wicked-good/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Winning a Predictive Maintenance Data Challenge with Engineering Expertise</title>
		<link>https://blogs.mathworks.com/deep-learning/2025/12/16/winning-a-predictive-maintenance-data-challenge-with-engineering-expertise/?s_tid=feedtopost</link>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Tue, 16 Dec 2025 15:42:47 +0000</pubDate>
				<category><![CDATA[AI Application]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=18976</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2025/12/phm-poster-scaled.jpg" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>




Co-author: Peeyush Pankaj

Peeyush Pankaj is an application engineer at MathWorks with a strong Aerospace background and deep domain expertise in vibrations and mechanical systems (engine... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2025/12/16/winning-a-predictive-maintenance-data-challenge-with-engineering-expertise/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="aligncenter wp-image-18979 size-full" src="https://blogs.mathworks.com/deep-learning/files/2025/11/PeeyushPankaj.jpg" alt="" width="400" height="400" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Co-author: <a href="https://www.linkedin.com/in/peeyush-pankaj/">Peeyush Pankaj</a></strong>
<h6></h6>
Peeyush Pankaj is an application engineer at MathWorks with a strong Aerospace background and deep domain expertise in vibrations and mechanical systems (engine lubrication circuit design &amp; analysis). In this blog post, he tells us about his experience at the 2025 Prognostics and Health Management Society Conference Data Challenge.</td>
</tr>
</tbody>
</table>
<h6></h6>
For the last several years, MathWorks has attended the <a href="https://phmsociety.org/" target="_blank" rel="noopener">Prognostics and Health Management (PHM) Society Conference</a> – a global conference focused on predictive maintenance applications. This year, the team participated in the <a href="https://data.phmsociety.org/phm-north-america-2025-conference-data-challenge/" target="_blank" rel="noopener">2025 PHM Data Challenge</a> – and took home <strong>first place</strong>. The MathWorks team comprised Peeyush Pankaj, Reece Teramoto, Shyam Joshi, Xiaomeng Peng, and Taylor Hearn.
<h6></h6>
&nbsp;
<h6></h6>
<div id="attachment_19062" style="width: 810px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-19062" decoding="async" loading="lazy" class="wp-image-19062" src="https://blogs.mathworks.com/deep-learning/files/2025/12/phm-poster-scaled.jpg" alt="" width="800" height="600" /><p id="caption-attachment-19062" class="wp-caption-text"><span data-teams="true">Shyam Joshi and Reece Teramoto present the team's winning solution at the PHM Society Conference 2025 in Bellevue, WA.</span></p></div>

&nbsp;
<h6></h6>
<h2>A Real-World Data Challenge</h2>
The 2025 PHM Data Challenge asked participants to predict when two components of a commercial jet engine would need maintenance. Using sensor data from four engines across thousands of flights, teams had to create models to estimate how many flights remained before three different maintenance events: High Pressure Turbine (HPT) shop visit, High Pressure Compressor (HPC) shop visit, and HPC water wash.

The three maintenance predictions made this a more complex problem than previous PHM data challenges. The dataset was intentionally realistic and messy, with missing sensors, noise, and flights out of order. And predictions that came too late were penalized more heavily. The teams faced a big challenge to generalize well and avoid overfitting the data.

This was no simple toy example.
<h6></h6>
<h2>Engineering Expertise + MATLAB = Win</h2>
This year, MathWorks had two advantages in the data challenge: deep engineering domain expertise and a knowledge of AI and Predictive Maintenance tools in MATLAB.

The team was led by <strong>Peeyush Pankaj</strong>, co-author of this post, whose prior career in aerospace engineering helped him lead the team to interpret degradation patterns, identify practical domain-specific features, and understand realistic engine behavior.

Next, Peeyush describes how MathWorks did it.
<h6></h6>
<h2>The Solution</h2>
<h6></h6>
<strong>Read the full Paper:</strong> <a href="https://papers.phmsociety.org/index.php/phmconf/article/view/4668" target="_blank" rel="noopener">Maintenance Service Events Prediction Modeling of Aircraft Gas Turbine Engines | Annual Conference of the PHM Society</a>
<h6></h6>
What made this year’s PHM Society Data Challenge particularly interesting was how closely it resembled the messiness of real engine prognostics. We were given only four engines for training, each with multiple failure-linked events that interact with one another the same way they do on a real fleet. The test engines operated in envelopes not seen in training, several sensors were entirely missing, and the individual flight files were shuffled out of sequence. This is very typical of fielded assets: a model must learn from whatever limited history is available and still generalize to engines of the same make and model that operate differently, age differently, and undergo maintenance at different intervals. The challenge captured that reality extremely well.
<h6></h6>
&nbsp;
<h6></h6>
&nbsp;

<div id="attachment_19047" style="width: 810px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-19047" decoding="async" loading="lazy" class="wp-image-19047" src="https://blogs.mathworks.com/deep-learning/files/2025/12/methodology2.png" alt="" width="800" height="295" /><p id="caption-attachment-19047" class="wp-caption-text">The approach used by the MathWorks team</p></div>
<h6></h6>
&nbsp;
<h6></h6>
To handle the missing sensing channels in the test and validation sets, we built <strong>virtual sensor models</strong> to reconstruct key pressures and temperatures. Once the physical variable set was complete, we introduced <strong>domain-informed features</strong> such as compressor efficiency drop, turbine temperature gradient change, pressure ratio decay across the engine core, and several thermodynamic health markers that typically reflect aging. In addition, the raw dataset consisted of up to eight snapshots per cycle, sometimes fewer, so we converted everything into cycle-level statistics. This preserved the underlying physics and made it possible to analyze degradation on a cycle-by-cycle basis rather than dealing with snapshot irregularities.
<h6></h6>
A major breakthrough came when we built <strong>global health indicators</strong> using the <a href="https://www.mathworks.com/help/predmaint/ref/healthindicatordesigner-app.html">Health Indicator Designer</a> app in Predictive Maintenance Toolbox. When plotted, the HPC health indicator showed clear upward recoveries after Water Wash events, confirming exactly what we see in real field operations: regular washing restores compressor health and extends the life of downstream modules. That insight influenced the modeling strategy. We used neural networks for HPT shop visit predictions, and for HPC and Water Wash predictions we used <strong>sequence-to-sequence LSTM models</strong> with <strong>custom loss functions</strong> that penalized incorrect predictions more severely when the maintenance event was near. This helped prevent late forecasts for safety-critical events. MATLAB’s <a href="https://www.mathworks.com/help/deeplearning/deep-network-designer-app.html">Deep Network Designer</a> and <a href="https://www.mathworks.com/help/deeplearning/ref/experimentmanager-app.html">Experiment Manager</a> were extremely helpful here, allowing us to iterate quickly through model architectures and training strategies without writing everything from scratch.
<h6></h6>
&nbsp;
<h6></h6>
<div id="attachment_19050" style="width: 810px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-19050" decoding="async" loading="lazy" class="wp-image-19049 aligncenter" src="https://blogs.mathworks.com/deep-learning/files/2025/12/pm-app.png" alt="" width="800" height="394" /><p id="caption-attachment-19050" class="wp-caption-text">Using Health Indicator Designer to design custom health indicators for HPC and HPT.</p></div>
<h6></h6>
<h6></h6>
&nbsp;
<h6></h6>
Since the challenge deliberately scrambled the order of flight files in the test set, we finally introduced a profile-based registration method that aligns the files chronologically by matching the shape of the predicted health indicators. This step ensured that the degradation sequence remained physically consistent, which improved our confidence in the predictions.

&nbsp;
<h6></h6>
&nbsp;
<h6></h6>
<div id="attachment_19050" style="width: 810px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-19050" decoding="async" loading="lazy" class="wp-image-19050" src="https://blogs.mathworks.com/deep-learning/files/2025/12/health-indicators.png" alt="" width="800" height="358" /><p id="caption-attachment-19050" class="wp-caption-text">Remaining Useful Life features such as event flags and post-event Health Indicator recovery metrics.</p></div>
<h6></h6>
&nbsp;
<h6></h6>
<h6></h6>
Overall, combining aircraft engine domain knowledge with productivity tools in MATLAB allowed us to move rapidly from noisy, inconsistent raw data to a complete, physics-aligned prognostics pipeline, ultimately resulting in first place in this year’s competition.
<h6></h6>
Congratulations to all the participants in the challenge and we hope to see you next year!
<h6></h6>
&nbsp;

&nbsp;]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MATLAB MCP Core Server Update: Bringing Your Coding Guidelines Directly to AI</title>
		<link>https://blogs.mathworks.com/deep-learning/2025/12/11/matlab-mcp-server-update-bringing-your-coding-guidelines-directly-to-ai/?s_tid=feedtopost</link>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Thu, 11 Dec 2025 13:37:18 +0000</pubDate>
				<category><![CDATA[Agentic AI]]></category>
		<category><![CDATA[Generative AI]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=19038</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2025/12/AddResourceCodingGuidelines.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>Last month, we announced the release of the MATLAB Model Context Protocol (MCP) Core Server, opening a new bridge between MATLAB and the next generation of AI agents. The response has been... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2025/12/11/matlab-mcp-server-update-bringing-your-coding-guidelines-directly-to-ai/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<span style="font-weight: 400;">Last month, we </span><a href="https://blogs.mathworks.com/deep-learning/2025/11/03/releasing-the-matlab-mcp-core-server-on-github/"><span style="font-weight: 400;">announced the release of the MATLAB Model Context Protocol (MCP) Core Server</span></a><span style="font-weight: 400;">, opening a new bridge between MATLAB and the next generation of AI agents. The response has been incredible, and we’ve been listening closely to how you are using these agents to accelerate your workflows.</span>

<span style="font-weight: 400;">Today, we are excited to share a new feature-driven update to the server (v0.3), which goes beyond just </span><i><span style="font-weight: 400;">executing</span></i><span style="font-weight: 400;"> code. This release introduces a fundamental shift in how your AI assistant understands your development environment: </span><b>MCP Resources</b><span style="font-weight: 400;">.</span>
<h6></h6>
&nbsp;
<h6></h6>
<h6></h6>
<div class="row"><div class="col-xs-12 containing-block"><div class="bc-outer-container add_margin_20"><videoplayer><div class="video-js-container"><video data-video-id="6386331065112" data-video-category="blog" data-autostart="false" data-account="62009828001" data-omniture-account="mathwgbl" data-player="rJ9XCz2Sx" data-embed="default" id="mathworks-brightcove-player" class="video-js" controls></video><script src="//players.brightcove.net/62009828001/rJ9XCz2Sx_default/index.min.js"></script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs("mathworks-brightcove-player").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();</script></div></videoplayer></div></div></div>
<h6></h6>
<h3><b>Beyond Tools: The Power of Context</b></h3>
<span style="font-weight: 400;">In our initial release, we focused on </span><b>Tools</b><span style="font-weight: 400;">—giving the AI the ability to run MATLAB code, evaluate expressions, and retrieve documentation. That’s the "hands" of the agent.</span>

<span style="font-weight: 400;">With today’s update, we are giving the agent "eyes."</span>

<span style="font-weight: 400;">The </span><b>Model Context Protocol</b><span style="font-weight: 400;"> isn't just about execution; it’s about </span><i><span style="font-weight: 400;">Context</span></i><span style="font-weight: 400;">. By adding support for </span><b>Resources</b><span style="font-weight: 400;">, the MATLAB MCP server can now feed structured read-only data directly into the Large Language Model’s (LLM) context window. This ensures the model knows </span><i><span style="font-weight: 400;">how</span></i><span style="font-weight: 400;"> you want your code written before it writes a single line.</span>
<h6></h6>
<h6></h6>
&nbsp;

&nbsp;
<h3><b>Feature Highlight: Standardizing Code with "MATLAB Coding Guidelines"</b></h3>
<span style="font-weight: 400;">We know that generating code is easy, but generating </span><i><span style="font-weight: 400;">compliant, production-ready</span></i><span style="font-weight: 400;"> code is hard. To demonstrate the power of Resources, we have connected the MATLAB MCP server directly to the </span><a href="https://github.com/matlab/rules"><span style="font-weight: 400;">MATLAB AI Coding Rules</span></a><span style="font-weight: 400;">.</span>

<span style="font-weight: 400;">Now, instead of prompting your agent with "Write this script and please remember to use camelCase and don't use i for loops," you can simply attach the </span><b>Coding Guidelines Resource</b><span style="font-weight: 400;">.</span>
<h6></h6>
<b>A Real-World Workflow: </b><span style="font-weight: 400;">Imagine you are asking an AI agent (like Claude Desktop or Cursor) to write a script that processes complex number arrays.</span>
<h6></h6>
<span style="font-weight: 400;">Without Context:</span>

<span style="font-weight: 400;">The model might generate a loop using i as an iterator:</span>

&nbsp;

&nbsp;
<div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;"><span class="comment">% Typical AI Output</span>
for i = 1:100
    y = x + 3i; <span class="comment">% Potentially ambiguous or error-prone if 'i' is overwritten</span>
end
</pre>
</div>
</div>
<h6></h6>
<h6></h6>
<span style="font-weight: 400;">With the MATLAB Coding Guidelines Resource:</span>

<span style="font-weight: 400;">You simply select the matlab://resources/coding_guidelines resource in your MCP client. The agent instantly reads the guidelines, specifically the rule regarding imaginary units and variable naming.</span>

<span style="font-weight: 400;">The Result:</span>

<span style="font-weight: 400;">The agent auto-corrects its behavior based on the guideline recommendation to "Use 1i or 1j for imaginary numbers" and avoids using i as a loop variable to prevent shadowing.</span>

&nbsp;

&nbsp;
<div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;"><span class="comment">% Output with MCP Resource attached</span>
for k = 1:100
    y = x + 3*1i; <span class="comment">% Adheres to MathWorks guidelines for imaginary units</span>
end
</pre>
</div>
</div>
&nbsp;
<h6></h6>
<span style="font-weight: 400;">This ensures your AI-generated code isn't just functional—it’s clean, maintainable, and adheres to the standards used by large engineering teams.</span>
<h6></h6>
<h6></h6>
&nbsp;
<h6></h6>
<h3><b>What Else is New?</b></h3>
<span style="font-weight: 400;">This release includes several other improvements driven by community feedback:</span>
<ul>
 	<li style="font-weight: 400;" aria-level="1"><b>Lazy Loading:</b><span style="font-weight: 400;"> We are optimizing the server startup. MATLAB will now "lazy load," meaning the server starts instantly and only launches the full MATLAB engine when you make your first tool call.</span></li>
 	<li style="font-weight: 400;" aria-level="1"><b>System Tests:</b><span style="font-weight: 400;"> We've added a robust suite of system tests to ensure stability across different OS environments.</span></li>
 	<li style="font-weight: 400;" aria-level="1"><b>Watchdog Logging:</b><span style="font-weight: 400;"> Improved debugging with dedicated logs for the server watchdog process.</span></li>
</ul>
&nbsp;
<h5></h5>
<h5></h5>
&nbsp;
<h3><b>Try It Out</b></h3>
<span style="font-weight: 400;">The updated MATLAB MCP Core Server is available now.</span>
<ol>
 	<li style="font-weight: 400;" aria-level="1"><b>Update your server:</b><span style="font-weight: 400;"> Get the latest release from our </span><a href="https://github.com/matlab/matlab-mcp-core-server/releases/tag/v0.3.0"><span style="font-weight: 400;">GitHub Repository</span></a><span style="font-weight: 400;">.</span></li>
 	<li style="font-weight: 400;" aria-level="1"><b>Explore the Guidelines:</b><span style="font-weight: 400;"> Check out the source of inspiration for our new resource at the </span><a href="https://github.com/mathworks/MATLAB-Coding-Guidelines"><span style="font-weight: 400;">MATLAB Coding Guidelines repo</span></a><span style="font-weight: 400;">.</span></li>
 	<li style="font-weight: 400;" aria-level="1"><b>Connect:</b><span style="font-weight: 400;"> Point your AI chat or agent (like Claude or IDEs supporting MCP) to the new server and look for the new Resources (in Claude Desktop, it is available with the + icon).</span></li>
</ol>
<span style="font-weight: 400;">We can’t wait to see what you build—and how cleanly you code it!</span>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MATLAB MCP Client is out on GitHub now!</title>
		<link>https://blogs.mathworks.com/deep-learning/2025/12/10/matlab-mcp-client-on-github/?s_tid=feedtopost</link>
		
		<dc:creator><![CDATA[Yann Debray]]></dc:creator>
		<pubDate>Wed, 10 Dec 2025 14:22:17 +0000</pubDate>
				<category><![CDATA[Agentic AI]]></category>
		<category><![CDATA[Generative AI]]></category>
		<guid isPermaLink="false">https://blogs.mathworks.com/deep-learning/?p=18997</guid>

					<description><![CDATA[<div class="overview-image"><img src="https://blogs.mathworks.com/deep-learning/files/2025/12/mcp-client-thumbnail.png" class="img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /></div><p>





Guest Writer: Shweta Pujari

Shweta Pujari is the Product Manager for AI and GenAI. In this blog post, she joins me to demonstrate how to use the new MATLAB MCP Client to build agentic... <a class="read-more" href="https://blogs.mathworks.com/deep-learning/2025/12/10/matlab-mcp-client-on-github/">read more >></a></p>]]></description>
										<content:encoded><![CDATA[<h6></h6>
<h6></h6>
<table style="background-color: #e2f0ff;">
<tbody>
<tr>
<td style="width: 120px; padding: 3px; vertical-align: middle;"><img decoding="async" loading="lazy" class="aligncenter wp-image-18998 size-full" src="https://blogs.mathworks.com/deep-learning/files/2025/12/shweta.jpg" alt="" width="1000" height="1000" /></td>
<td style="vertical-align: middle; padding: 3px;"><strong>Guest Writer: <a href="https://www.linkedin.com/in/shweta-kapdoskar" target="_blank" rel="nofollow noopener noreferrer">Shweta Pujari</a></strong>
<h6></h6>
Shweta Pujari is the Product Manager for AI and GenAI. In this blog post, she joins me to demonstrate how to use the new MATLAB MCP Client to build agentic workflows in the MATLAB language.</td>
</tr>
</tbody>
</table>
<h6></h6>
MathWorks has released a new capability on GitHub – the MATLAB MCP Client – enabling users to easily connect MATLAB-based AI workflows to external services and third-party tools (via HTTP).
<h6></h6>
<a href="https://github.com/matlab-deep-learning/mcpHTTPClient" target="_blank" rel="noopener">https://github.com/matlab-deep-learning/mcpHTTPClient</a>
<h6></h6>
<h6></h6>
<em>Note:</em> About a month earlier, MathWorks also released the <a href="https://blogs.mathworks.com/deep-learning/2025/11/03/releasing-the-matlab-mcp-core-server-on-github/" target="_blank" rel="noopener">MATLAB MCP Core Server</a> on GitHub, which provides a reference MCP implementation for calling MATLAB from third party AI chats and agents.
<h6></h6>
<h6></h6>
In this post, we’ll break down what the MCP client is, how it works, and why it’s a big deal for engineers building AI solutions in MATLAB.
<h6></h6>
<h6></h6>
<h6></h6>
<h2>What is the MATLAB MCP Client?</h2>
<h6></h6>
<strong>Model Context Protocol (MCP)</strong> is an emerging standard that defines how AI models communicate with external tools and services. Think of MCP as a language that both an AI model and a tool server understand – it covers how to list what tools are available and how to invoke those tools with specific inputs, getting back results in a structured way. Many advanced LLM applications today use agents that can call external functions (for example, an AI assistant that calls a weather API or database query). MCP provides a formal framework for this kind of tool calling so that any AI client can talk to any tool server that speaks MCP.
<h6></h6>
With this capability, you can implement an MCP client entirely in MATLAB code. In practical terms, this add-on allows MATLAB to connect to an MCP-compatible server over HTTP and use the tools that server offers. Once connected, MATLAB can list the available tools on that server and then call those tools on demand. Importantly, this integration is designed to work hand-in-hand with the <a href="https://www.mathworks.com/matlabcentral/fileexchange/163796-large-language-models-llms-with-matlab">Large Language Models (LLMs) with MATLAB</a> add-on, enabling the language model to automatically decide when to use these tools as needed.
<h6></h6>
<h6></h6>
<h6></h6>
<img decoding="async" loading="lazy" class="aligncenter wp-image-19033" src="https://blogs.mathworks.com/deep-learning/files/2025/12/mcp-client-thumbnail.png" alt="" width="400" height="309" />
<h6></h6>
<h6></h6>
<h2>Key capabilities of the MATLAB MCP Client</h2>
<h6></h6>
<ol>
 	<li><strong>Connecting to Tools via MCP Servers: </strong>You can create an MCP client in MATLAB that connects to any streamable HTTP MCP server by specifying its URL (endpoint). Upon connection, the client automatically fetches the list of available tools from the server. This means MATLAB instantly knows what functions the server can perform (e.g., “get_weather”, “run_simulation”, “query_database”, etc.), along with details about each tool’s inputs and outputs.</li>
 	<li><strong>Calling External Tools: </strong>With the MCP client, calling an external tool becomes as straightforward as calling a local MATLAB function. The add-on provides a high-level function <em>callTool </em>for this purpose. You simply pass in the tool name and required parameters, and <em>callTool </em>handles the communication with the server, returning the result to MATLAB. There’s no need to manually craft HTTP requests or parse JSON – the client does that behind the scenes. This dramatically simplifies integration with external APIs or services.</li>
 	<li><strong>Integrating with LLM Workflows: </strong>Perhaps the most exciting capability is enabling <strong>“agentic” </strong>AI workflows. By combining this MCP client with the LLMs with MATLAB add-on, you allow a large language model in MATLAB to autonomously decide when to call an external tool to fulfill a user’s request. The MCP client exposes the server’s tools to the LLM: you convert the list of tools into a form the model understands (<em>openAIFunction </em>objects for OpenAI’s function-calling interface) and pass them into your LLM session. Then, when you prompt the LLM, it can choose to output a tool call (including the tool name and arguments) if it determines that using a tool is the best way to get the answer. MATLAB captures this intended function call, and you can execute it via <em>callTool(client, toolRequest) </em>to get the result. In short, the MCP client makes it possible for an AI assistant in MATLAB to not just talk about external data or actions, but to actually perform those actions by invoking real services.</li>
</ol>
<h6></h6>
<h6></h6>
<h6></h6>
<h2>Get started with the MATLAB MCP client</h2>
<div class="S1">This example demonstrates how to easily build an MCP Client in MATLAB to connect with an MCP server and use an LLM to call the server tools. It uses a single tool from a <a href="https://production-server-demo.mathworks-workshop.com/~files/mcp-production-server/index.html">prime sequence MCP server</a>.</div>
&nbsp;

&nbsp;
<h3 id="TMP_3b5c" class="S7">Set-up the interface to call OpenAI LLMs</h3>
<div class="S1">Make sure you get the latest version of the <a href="https://github.com/matlab-deep-learning/llms-with-matlab">LLM-with-MATLAB</a> repo:</div>
<div>
<h6></h6>
<div class="S14">Create a .env file with your OPENAI_API_KEY</div>
<div class="preformatted-plain">
<pre class="S18">OPENAI_API_KEY=sk-proj-xxxxx</pre>
</div>
<h6></h6>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">gitclone("https://github.com/matlab-deep-learning/llms-with-matlab")
addpath("llms-with-matlab")
loadenv '.env'
</pre>
</div>
</div>
<h6></h6>
&nbsp;
<h3 id="TMP_004e" class="S8">Build the MCP client</h3>
<div class="S1">Here is how you can connect to the MCP server endpoint from MATLAB:</div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">endpoint = "https://production-server-demo.mathworks-workshop.com/primeSequence/mcp";
client = mcpHTTPClient(endpoint)
</pre>
</div>
<h6></h6>
<pre style="background: none;">client = 
  mcpHTTPClient with properties:

       Endpoint: "https://production-server-demo.mathworks-workshop.com/primeSequence/mcp"
    ServerTools: {[1×1 struct]}
</pre>
<h6></h6>
<h6></h6>
<div class="S1">The first step is to discover the tools made available by the MCP server. You can loop to list them all. Here there is only one:</div>
<div class="CodeBlock">
<div class="inlineWrapper"></div>
</div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">serverTools = client.ServerTools;
for i = 1:length(serverTools)
    disp(serverTools{i}.name)
    disp(serverTools{i}.description)
    disp('---')
end
</pre>
</div>
<h6></h6>
<pre style="background: none;"> 
primeSequence
Return the first N primes of the given sequence type. Four sequence types supported: Eisenstein, Balanced, Isolated and Gaussian.
---
</pre>
<h6></h6>
<h6></h6>
<div class="S1">Next step is to look up the arguments required to call a tool.</div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">tool1 = serverTools{1};
toolName = tool1.name;
client.ServerTools{1}.inputSchema
</pre>
</div>
<h6></h6>
The input schema informs which arguments or properties are required:
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">client.ServerTools{1}.inputSchema.properties</pre>
</div>
<h6></h6>
<pre style="background: none;">ans = struct with fields:
       n: [1×1 struct]
    type: [1×1 struct]
</pre>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">client.ServerTools{1}.inputSchema.properties.n
</pre>
</div>
<h6></h6>
<pre style="background: none;">ans = struct with fields:
           type: 'number'
    description: 'Length of the generated sequence'
</pre>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">client.ServerTools{1}.inputSchema.properties.type</pre>
</div>
<h6></h6>
<pre style="background: none;">ans = struct with fields:
           type: 'string'
    description: 'Name of the sequence to generate'
</pre>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">client.ServerTools{1}.inputSchema.required</pre>
</div>
<h6></h6>
<pre style="background: none;">ans = 2×1 cell array
'n'       
'type'    
</pre>
<h6></h6>
<h6></h6>
&nbsp;
<h3 id="TMP_4afe" class="S12">Integrate the MCP client to the model</h3>
<div class="S1">The following functions are provided by the LLMs with MATLAB repo. In this example, the OpenAI service is used to provide the Large Language Model.</div>
<div></div>
<div>
<div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">f = openAIFunction(serverTools)</pre>
</div>
<h6></h6>
<pre style="background: none;">f = 
  openAIFunction with properties:

    FunctionName: "primeSequence"
     Description: "Return the first N primes of the given sequence type. Four sequence types supported: Eisenstein, Balanced, Isolated and Gaussian."
      Parameters: [1×1 struct]
</pre>
</div>
</div>
<h6></h6>
<div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">model = openAIChat(Model="gpt-5-mini",Tools=f)</pre>
</div>
<h6></h6>
<pre style="background: none;">model = 
  openAIChat with properties:

           ModelName: "gpt-5-mini"
         Temperature: 1
                TopP: 1
       StopSequences: [0×0 string]
             TimeOut: 10
        SystemPrompt: []
      ResponseFormat: "text"
     PresencePenalty: 0
    FrequencyPenalty: 0
       FunctionNames: "primeSequence"
</pre>
</div>
<h6></h6>
<h6></h6>
Let the model select which tool to call. Here there is only one tool to choose from:
<h6></h6>
<div>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">[~,completeOutput] = generate(model,"generate a sequence of 10 prime numbers")</pre>
</div>
<h6></h6>
<pre style="background: none;">completeOutput = struct with fields:
           role: 'assistant'
        content: []
     tool_calls: [1×1 struct]
        refusal: []
    annotations: []
</pre>
</div>
<h6></h6>
<div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">completeOutput.tool_calls</pre>
</div>
<h6></h6>
<pre style="background: none;">ans = struct with fields:
          id: 'call_5TOPVJ5zftW3WWydHQ0fmpyR'
        type: 'function'
    function: [1×1 struct]
</pre>
</div>
<h6></h6>
<h6></h6>
Now just integrate this logic in an agentic loop:
<div>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">toolRequest = completeOutput.tool_calls(1).function</pre>
</div>
<h6></h6>
<pre style="background: none;">toolRequest = struct with fields:
         name: 'primeSequence'
    arguments: '{"n":10,"type":"Eisenstein"}'
</pre>
</div>
<h6></h6>
<div>
<h6></h6>
<div style="position: relative; background: #f9fafb; border: 1px solid #d1d5db; border-radius: 6px; padding: 1rem; font-family: Consolas,monospace; color: #111827;">
<pre id="matlab-snippet" style="margin: 0; padding: 0; border: none; background: none; color: inherit; white-space: pre; line-height: 1.4;">output = callTool(client,toolRequest)</pre>
</div>
<h6></h6>
<pre style="background: none;">output = "[2,5,11,17,23,29,41,47,53,59]"</pre>
</div>
<h6></h6>
&nbsp;
<h6></h6>
If you want to see this workflow in action, watch this video to see how you can create an MCP client in MATLAB and use LLMs to call tools from the connected MCP server.

&nbsp;
<h6></h6>
<div class="row"><div class="col-xs-12 containing-block"><div class="bc-outer-container add_margin_20"><videoplayer><div class="video-js-container"><video data-video-id="6386236146112" data-video-category="blog" data-autostart="false" data-account="62009828001" data-omniture-account="mathwgbl" data-player="rJ9XCz2Sx" data-embed="default" id="mathworks-brightcove-player" class="video-js" controls></video><script src="//players.brightcove.net/62009828001/rJ9XCz2Sx_default/index.min.js"></script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs("mathworks-brightcove-player").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();</script></div></videoplayer></div></div></div>

This code can be found here: <a href="https://github.com/mathworks/MATLAB-AI-Blog/tree/main/matlab-mcp-client-on-github">https://github.com/mathworks/MATLAB-AI-Blog/tree/main/matlab-mcp-client-on-github</a>
<h6></h6>
Let us know what you will build with this!]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
