Introducing the New MATLAB Extension for Visual Studio Code - MATLAB
Video Player is loading.
Current Time 0:00
Duration 3:21
Loaded: 4.92%
Stream Type LIVE
Remaining Time 3:21
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 3:21

    Introducing the New MATLAB Extension for Visual Studio Code

    The new MATLAB® extension for Visual Studio Code makes it easier to edit and develop MATLAB code in Visual Studio Code. The extension provides several basic features, regardless of whether you have MATLAB installed on your system. These features include syntax highlighting, code snippets, and code folding.

    If you have MATLAB R2021a or later installed on your system, you have access to an additional set of advanced code-editing features such as tab completion, code analysis, and code navigation. Additionally, this extension works well with other extensions in the marketplace, such as the Live Share extension or GitHub® Copilot.

    Used with permissions from Microsoft.

    Published: 29 Aug 2023

    In this video, we'll see how you can use the newly launched MATLAB extension by MathWorks to directly edit your code in Visual Studio Code. While providing support for editing MATLAB code, the extension includes features such as tab completion, code analysis, code navigation, and more. Getting started with the extension is easy. You can install it directly from the Visual Studio Code marketplace by searching for MATLAB extension by MathWorks.

    Now that we've installed the extension, we'll create a simple class that performs some basic mathematical operations. To start, we are going to create a new MATLAB file.

    We'll begin by defining our class using the extensions classdef code snippet to autopopulate the structure. We can just fill in the class properties and methods. And while I do so, you will notice that all the code has syntax highlighting.

    You will also see that as soon as I start typing, we get a suggestion list. And tab completion helps us quickly fill in the rest. We can use tab completion and code snippets again to instantly pull in the built-in functions we want to use and define the parameters.

    Now we are going to use tab completion to pull in the round function. If we have errors in our code or some suggestions to improve it further, these will be shown in the problems panel in VS Code. For common issues and suggestions, you can address these using one of the quick fixes suggested by the extension.

    If you're using multiple functions in a file, you can navigate to the definition of your function using the Go To Definition option. Or you can just take a quick peek.

    Some of the features that we just saw require MATLAB to be launched in the background. If you have MATLAB installed locally and on the system path, you should be good to go. Otherwise, you will need to specify the path to your MATLAB installation using the MATLAB install path setting.

    The MATLAB extension plays nicely with other VS Code extensions. For example, you can use it with the Live Share extension to collaboratively edit with others in real time. Or you can try using GitHub Copilot as your AI pair programmer.

    If you use MATLAB in Visual Studio Code, install the extension, and try it for yourself. Any and all feedback is welcome. If you encounter any technical issues or have some great enhancement ideas, let us know what you think by creating an issue on GitHub or sending us an email.