https://github.com/shinyypig/matlab-in-vscode
A vscode extension for matlab.
https://github.com/shinyypig/matlab-in-vscode
extension matlab vscode
Last synced: 10 days ago
JSON representation
A vscode extension for matlab.
- Host: GitHub
- URL: https://github.com/shinyypig/matlab-in-vscode
- Owner: shinyypig
- License: mit
- Created: 2023-03-23T05:38:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-12T12:13:37.000Z (about 1 month ago)
- Last Synced: 2025-04-14T00:12:56.366Z (10 days ago)
- Topics: extension, matlab, vscode
- Language: TypeScript
- Homepage:
- Size: 2.48 MB
- Stars: 51
- Watchers: 2
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Matlab in VSCode



This is a VSCode extension for Matlab. It provides the following features.
Major:
- view variables directly in VSCode
- run a cell in matlab by press `ctrl+enter` or `cmd+enter`
- run current line and move to next in matlab by press `shift+enter`
- syntax highlighting for `.m` fileMinor:
- run a complete matlab .m file
- interrupt matlab process by clicking the stop button
- change the work directory of matlab to the directory of the current file
- open the workspace of matlab to inspect the variables
- open the current file in matlab editor for debugging or other purposeAll functions can be accessed by clicking the button in the menu bar. If matlab terminal is not started, the extension will start it automatically. Then, you need to reclick the button to run the command.
![]()
Click [here](https://marketplace.visualstudio.com/items?itemName=shinyypig.matlab-in-vscode) to install the extension.
## Usage
If you are a **windows** user, you may need to installed the MATLAB Engine API for Python, check this [link](https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html) for more details. Then you need to checkout the `matlabPybackend` option in the settings of the extension.
If you are a **linux** or **mac** user, the default settings are fine. Unless the matlab excuable file is not in the path, you can check the `matlabCMD` option in the settings of the extension.
## View Workspace
You can click the button in the menu bar to open a webview to inspect the variables. Though it is not as powerful as the matlab workspace, it is enough for simple inspection.
![]()
Furthermore, you now can click the variable name to see the details of the variable.
![]()
Notice that a file named `matlabInVSCodeVariableInfo.csv` will be generated in the current directory. It is used to store the variable information. Normally, this file will be automatically deleted immediately. However, if some error occurs, it may not be deleted. You should delete it manually.
**Important!!!** You need to open a folder as workspace in the VSCode to make sure that the extension can find the `matlabInVSCodeVariableInfo.csv` file.
## Cell Mode
You can split your code by `%%`, click the run cell button or simply press `ctrl+enter` (mac: `cmd+enter`) to run the active cell.
![]()
## View Documentation
You can right click the function name and select `Show Matlab Document` to view the documentation of the function.
![]()
## Settings
- `matlabCMD`: The command to start the Matlab terminal, default is `matlab -nodesktop -nosplash`. If the python backend is used, it will be ignored. In addition, for windows users, it is recommended to use `matlabPybackend`.
- `matlabMoveToNext`: If set to true, the cursor will move to the next line after running the current line. Default is true.
- `matlabPybackend`: It is recommended to use the python backend in Windows. Check this [link](https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html) for installing MATLAB Engine API for Python.
- `matlabPythonPath`: If you want to specify the python path, you can set it here.
- `matlabStartup`: the code to run after starting the matlab, default is empty, you can add some code to set the default figure style, for example:```json
"matlab-in-vscode.matlabStartup": [
"addpath(genpath('./'));",
"set(groot, 'defaultLineLineWidth', 2);",
"set(groot, 'DefaultLineMarkerSize', 8);",
"set(groot, 'defaultAxesFontSize', 18);",
"set(groot, 'defaultAxesXGrid', 'on');",
"set(groot, 'defaultAxesYGrid', 'on');",
"set(groot, 'defaultAxesBox', 'on');",
"set(groot, 'defaultLegendBox', 'off');",
"format compact;"
],
```## Change Log
See [CHANGELOG.md](CHANGELOG.md).