The MATLAB Blog

Practical Advice for People on the Leading Edge

MATLAB extension for Visual Studio Code: Now with code execution

Back in April last year, I announced the MATLAB extension for Visual Studio Code on The MATLAB Blog and everyone at MathWorks was blown away by its popularity. In less than a year there have been over 150,000 installs of the MATLAB extension via the Visual Studio Marketplace, the announcement blog post is one of the most popular blogs across all of MATLAB Central and there has been a lot of active discussion on the extension’s GitHub repository including enhancement requests and bug reports. It’s safe to say that it has been a great success.
If you are new here and are wondering what all the fuss is about with respect to MATLAB and Visual Studio Code, you can check out this YouTube video alongside reading my original blog post announcing the release of the first version. Today’s post will focus on what’s new.

Pull requests are welcome

Split into two repositories,MATLAB-extension-for-vscode and MATLAB-language-server, the project has been available on GitHub since the beginning and community contribution is encouraged. It has been great to see contributions from people outside of MathWorks including Tiago Vilela, who used the MATLAB Language server to provide MATLAB support for the Neovim editor.
We've also had pull requests from Doron Behar and Moeta Yuko fixing various things. Thank you so much to everyone who has contributed so far and we look forward to more collaboration with the community.

Listening to your feedback

Being a developer, product manager or advocate of any popular piece of software can be a wild ride emotionally. On the one hand, you get great feedback like this
Screenshot 2024-02-26 172419.png
Positive with a side order of constructive suggestion, something we can work with. We received many comments like this in social media, via email and in one to one discussions with users. However, we also received a few comments like this.
waste_of_time.png
Ouch! Clearly, we fell way below this user’s expectations and we are sorry that the first release may have come up short for some users. We didn’t want to allow “perfect” to be the enemy of “good” and we felt the first release had a lot of useful functionality, so we released it into the wild. Our goal was to provide a solid foundation that could be built upon quickly in collaboration with the community and it's working! Over 150,000 users so far, contributions from the community and fast iteration on bug fixes. There have been 10 updates since the first release in less than a year. We are really happy with these results.
With that said, the lack of code execution from within Visual Studio Code was a common complaint among users, even among MathWorkers. It was also one of the first things requested on the project's GitHub issues page. Everyone wanted it!

Giving you what you want: MATLAB code execution from Visual Studio Code

So now we've got it. Ensure that you've installed at least version 1.2.0 of the MATLAB extension for Visual Studio Code alongside a copy of MATLAB that's at R2021a or above and you can run MATLAB programs right from Visual Studio Code.
RunVSCode1.gif
As you can see, just push the run button and your code will run in the MATLAB terminal. You can either continue editing or interact with the terminal further, whatever suits you best at the time.
Plots are rendered in a separate window, exactly as if you had run them from MATLAB Desktop.
VSCode_plot.gif
Speaking of MATLAB Desktop, you can access that at any time by typing desktop into the Visual Studio Code MATLAB terminal. It will be connected to the same workspace you are using from Visual Studio Code.

What we haven't given you: Debugging

The addition of code execution to the MATLAB extension for Visual Studio Code makes it much more useful and we hope you'll like it. The next obvious thing to request is debugging support and, if this important to you, please do add your voice to the discussion over at the issues section on GitHub along with everything else that you'd like.
The team are enjoying developing and delivering this functionality to you and we look forward to seeing you play with it, discussing it and letting us know what you want next!
|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.