The MATLAB Blog

Practical Advice for People on the Leading Edge

Debugging support in the MATLAB extension for Visual Studio Code

Since its April 2023 launch, the MATLAB extension for Visual Studio Code has been extremely popular with over 329,000 installs via the Visual Studio Marketplace at the time of writing. Our development approach to this extension has been to release early and often, responding to feedback from the community as we go.

You asked for debugging support for MATLAB in Visual Studio Code

One of the most common pieces of feedback we received was that you wanted debugging support as soon as possible. Royi Avital was the first user to open up a GitHub issue with the feature request but many other people added thumbs ups and other comments which served to show us how important this feature is to you.
One of these comments, from GitHub user fspinar made our day.
Positive feedback like this, combined with a clear set of feature requests are extremely motivating for the development team.

So we gave you debugging support for MATLAB in Visual Studio Code

Let's start with a piece of code I am noodling around with right now. I can open and run it in Visual Studio Code and have been able to do this since the March 2024 release.
VSCodeDebug1.gif
With the latest version, released this week, I can add breakpoints to pause code execution. When I run the code I can view the values of variables in the “Variables” section of the “Run and Debug” view, execute code in the MATLAB terminal and hover my mouse over variables in the editor to see their value right now. All of the usual debugging controls are there including Continue, Step Over, Step Into, Step Out, Restart and Stop.
VSCodeDebug2.gif
Conditional breakpoints are also supported. Right click on the line number you want to set a conditional break point and select it from the resulting context menu. Add the condition, press Enter and then run the code. In the following video, I ask it to break every 200 iterations and take a look at the plot after the first set of 200.
VSCodeDebug3.gif
With that I think we've satisfied the three points in Royi's feature request. There are a couple of things that don't work yet that the team are aware of such as logpoints and triggered breakpoints. If either of these things are issues for you then please join the discussion over at the GitHub issues page for the extension.
I encourage you to try out this latest version, let us know how you get on and tell us what you'd like to see next in the MATLAB extension for Visual Studio Code!

Resources and further reading

|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。