Skip to content

Commit 78f9c39

Browse files
prabhakk-mwkrisctl
authored andcommitted
Adds install guide for running MATLAB in Jupyter Notebooks Using VS Code.
fixes #24 fixes #41
1 parent 7734670 commit 78f9c39

File tree

10 files changed

+87
-29
lines changed

10 files changed

+87
-29
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Run MATLAB® code in Jupyter® environments such as Jupyter notebooks, JupyterLa
1515
- [Install](#install)
1616
- [Install from PyPI](#install-from-pypi)
1717
- [Build from Source](#build-from-source)
18+
- [Using VS Code](#using-vs-code)
1819
- [Using JupyterHub and The Littlest JupyterHub](#using-jupyterhub-and-the-littlest-jupyterhub)
1920
- [Using Simulink](#using-simulink)
2021
- [Troubleshooting](#troubleshooting)
@@ -92,11 +93,15 @@ python -m pip install .
9293
install-matlab-kernelspec
9394
```
9495

96+
### Using VS Code
97+
98+
You can use this package to run MATLAB in Jupyter notebooks using VS Code. For instructions, see [Run MATLAB in Jupyter Notebooks Using VS Code](https://github.com/mathworks/jupyter-matlab-proxy/blob/main/install_guides/vscode/README.md).
99+
95100
### Using JupyterHub and The Littlest JupyterHub
96101

97102
To use MATLAB with JupyterHub, install the `jupyter-matlab-proxy` Python package in the Jupyter environment launched by your JupyterHub platform. For example, if your JupyterHub platform launches Docker containers, install this package in the Docker image used to launch those containers, using the instructions for [Using MATLAB Integration _for Jupyter_ in a Docker Container](https://github.com/mathworks-ref-arch/matlab-integration-for-jupyter).
98103

99-
To use MATLAB with [The Littlest JupyterHub (TLJH)](https://tljh.jupyter.org/en/stable/index.html#), see [MATLAB Integration for Jupyter on The Littlest JupyterHub](https://github.com/mathworks/jupyter-matlab-proxy/jupyter-matlab-proxy/install_guides/the-littlest-jupyterhub/README.md). You might use this if you want to set up JupyterHub on a single server for a small number of users, such as students in a class.
104+
To use MATLAB with [The Littlest JupyterHub (TLJH)](https://tljh.jupyter.org/en/stable/index.html#), see [MATLAB Integration for Jupyter on The Littlest JupyterHub](https://github.com/mathworks/jupyter-matlab-proxy/blob/main/install_guides/the-littlest-jupyterhub/README.md). You might use this if you want to set up JupyterHub on a single server for a small number of users, such as students in a class.
100105

101106
### Using Simulink
102107

install_guides/the-littlest-jupyterhub/README.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,46 @@
11
# MATLAB Integration for Jupyter on The Littlest JupyterHub
22

3-
This guide shows how to set up MATLAB and the [MATLAB Integration for Jupyter](https://github.com/mathworks/jupyter-matlab-proxy) on the [The Littlest JupyterHub (TLJH)](https://tljh.jupyter.org/en/stable/index.html#). You might use this if you want to set up JupyterHub on a single server for a small number of users, such as students in a class.
3+
This guide shows how to set up MATLAB and the [MATLAB Integration for Jupyter](https://github.com/mathworks/jupyter-matlab-proxy) on the [The Littlest JupyterHub (TLJH)](https://tljh.jupyter.org/en/stable/index.html). You might use TLJH if you want to set up JupyterHub on a single server for a small number of users, such as students in a class.
44

55

66
## Set up TLJH
77

8-
The [TLJH Documentation](https://tljh.jupyter.org/en/stable/install/index.html) contains instructions for installing TLJH in different environments.
9-
10-
Once you have a working TLJH stack, you can add MATLAB into your TLJH stack using the MATLAB Plugin for The Littlest JupyterHub.
8+
The [TLJH Documentation](https://tljh.jupyter.org/en/stable/install/index.html) contains instructions for installing TLJH in different environments. Set up a working TLJH stack.
119

1210
## Add MATLAB to TLJH Installation
13-
This repository contains `tljh-matlab`, the [MATLAB Plugin for The Littlest JupyterHub](https://github.com/mathworks/jupyter-matlab-proxy/jupyter-matlab-proxy/install_guides/the-littlest-jupyterhub/tljh-matlab/README.md).
14-
15-
Use the plugin to install MATLAB, its dependencies, and the MATLAB integration for Jupyter in TLJH.
1611

17-
To install the MATLAB plugin, run the `bootstrap` script from your TLJH installation process again, and add the `tljh-matlab` plugin:
12+
Add MATLAB to your TLJH installation by using the MATLAB Plugin for The Littlest JupyterHub. To install the MATLAB plugin, run the `bootstrap` script from your TLJH installation process again, and include `-- plugin tljh-matlab` plugin:
1813

1914
```bash
2015
curl -L https://tljh.jupyter.org/bootstrap.py \
2116
| sudo python3 - \
2217
--plugin tljh-matlab
2318
```
2419

25-
For more information on installing plugins into a TLJH environment, see [Customizing the Installer *(TLJH Docs)*](https://tljh.jupyter.org/en/latest/topic/customizing-installer.html#customizing-the-installer).
26-
27-
To customize the MATLAB plugin, for example to choose which MATLAB toolboxes to install, see [MATLAB Plugin for The Littlest JupyterHub](https://github.com/mathworks/jupyter-matlab-proxy/tree/main/install_guides/the-littlest-jupyterhub/tljh-matlab/README.md).
20+
For detailed instructions on using and customizing the plugin, such as the version and toolboxes of MATLAB it installs, see the [MATLAB Plugin for The Littlest JupyterHub](https://github.com/mathworks/jupyter-matlab-proxy/tree/main/install_guides/the-littlest-jupyterhub/tljh-matlab/README.md).
2821

29-
## Setting Up TLJH with MATLAB in Docker: Quick Demo
22+
## Example: Setting Up TLJH with MATLAB in Docker
3023

31-
Execute the [start-container-with-tljh-matlab.sh](./start-container-with-tljh-matlab.sh) script to efficiently set up a sample TLJH environment with MATLAB & The MATLAB Integration for Jupyter installed within a Docker container.
24+
Run the [start-container-with-tljh-matlab.sh](./start-container-with-tljh-matlab.sh) script to quickly set up a TLJH environment with MATLAB and the MATLAB Integration for Jupyter installed within a Docker container.
3225

3326
```bash
3427
./start-container-with-tljh-matlab.sh
3528
```
3629

37-
Once initialized, your JupyterHub server will be accessible for notebook hosting at **http://Your-FQDN:12000**. You can view it in your browser via **http://localhost:12000/**.
30+
Your JupyterHub server will be accessible for hosting Jupyter Notebooks at `http://Your-FQDN:12000`. You can view it in your browser at `http://localhost:12000/`.
3831

3932
![JupyterHub Login Page](https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/tljh.png)
4033

4134
Access JupyterHub using the default credentials: the username is `admin` and the password is `password`.
42-
You can update these default values either, in the [start-container-with-tljh-matlab.sh](./start-container-with-tljh-matlab.sh) script, or from the Jupyter Admin UI.
35+
You can update these default values either in the [start-container-with-tljh-matlab.sh](./start-container-with-tljh-matlab.sh) script, or from the Jupyter Admin interface.
4336

44-
To install a different release of MATLAB or to install different MATLAB toolboxes within the TLJH instance, adjust the environment variables in the [.matlab_env](./.matlab_env) file accordingly and re-run `start-container-with-tljh-matlab.sh`.
37+
To install a different release of MATLAB or to install different MATLAB toolboxes within the TLJH instance, modify the environment variables in the [.matlab_env](./.matlab_env) file accordingly and run `start-container-with-tljh-matlab.sh` again.
4538

4639
## Learn More
4740

48-
- [The Littlest JupyterHub Official Documentation (TLJH)](https://tljh.jupyter.org/en/stable/index.html).
49-
- [When to Use the Littlest JupyterHub (TLJH)](https://tljh.jupyter.org/en/stable/topic/whentouse.html).
50-
- [Plugins (TLJH)](https://tljh.jupyter.org/en/stable/contributing/plugins.html).
41+
- [The Littlest JupyterHub Official Documentation (TLJH)](https://tljh.jupyter.org/en/stable/index.html)
42+
- [When to Use the Littlest JupyterHub (TLJH)](https://tljh.jupyter.org/en/stable/topic/whentouse.html)
43+
- [Plugins (TLJH)](https://tljh.jupyter.org/en/stable/contributing/plugins.html)
5144

5245

5346
----

install_guides/the-littlest-jupyterhub/tljh-matlab/README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# MATLAB Plugin for The Littlest JupyterHub
22

3-
A plugin for running [MATLAB® Integration for Jupyter on The Littlest JupyterHub](https://github.com/mathworks/jupyter-matlab-proxy/jupyter-matlab-proxy/install_guides/the-littlest-jupyterhub/README.md).
3+
This guide shows you now to use the MATLAB Plugin to install [MATLAB on The Littlest JupyterHub](https://github.com/mathworks/jupyter-matlab-proxy/jupyter-matlab-proxy/install_guides/the-littlest-jupyterhub/README.md).
44

55
## Background
66

7-
The Littlest JupyterHub supports [plugins](https://tljh.jupyter.org/en/latest/contributing/plugins.html) that provide additional features. The MATLAB plugin for TLJH, `tljh-matlab`, installs:
7+
The Littlest JupyterHub supports [plugins](https://tljh.jupyter.org/en/latest/contributing/plugins.html) that provide additional features. The MATLAB plugin for TLJH installs:
8+
89
* a specified version of MATLAB, as well as any MATLAB toolboxes
910
* the system libraries that MATLAB requires
1011
* the [MATLAB Integration for Jupyter](github.com/mathworks/jupyter-matlab-proxy), for running MATLAB in Jupyter notebooks and accessing the MATLAB environment from Jupyter.
1112

12-
## Usage
13-
To install the MATLAB plugin for TLJH include `--plugin tljh-matlab` in the Installer Script.
14-
See [Customizing the Installer](https://tljh.jupyter.org/en/latest/topic/customizing-installer.html) for more information.
13+
## Using the Plugin
14+
To install the MATLAB plugin for TLJH, include `--plugin tljh-matlab` in the Installer Script.
1515

1616
For example, the following command sets up an `admin_user` with `admin_password` and installs `tljh-matlab`:
1717
```bash
@@ -21,8 +21,11 @@ curl -L https://tljh.jupyter.org/bootstrap.py
2121
--plugin tljh-matlab
2222
```
2323

24-
## Customization
25-
To customize the default values used by the plugin, set the relevant environment variables before using the bootstrap command:
24+
For more information on customizing the TLJH installer, see [Customizing the Installer (TLJH)](https://tljh.jupyter.org/en/latest/topic/customizing-installer.html).
25+
26+
27+
## Customizing MATLAB Installation
28+
To customize the default values used by the plugin to install MATLAB, set the relevant environment variables before using the bootstrap command:
2629

2730
| Environment Variable Name | Default Values | Notes |
2831
|---|---|---|
@@ -31,10 +34,10 @@ To customize the default values used by the plugin, set the relevant environment
3134
| MATLAB_INSTALL_DESTINATION | /opt/matlab/R2024b | Specify the path to the location where you want to install MATLAB. |
3235

3336

34-
For example, to customize the plugin to install MATLAB R2023b and Simulink, run:
37+
For example, to customize the plugin to install MATLAB R2024b and Simulink, run:
3538
```bash
3639
curl https://tljh.jupyter.org/bootstrap.py
37-
| env MATLAB_RELEASE=R2023b MATLAB_PRODUCT_LIST="MATLAB Simulink" \
40+
| env MATLAB_RELEASE=R2024b MATLAB_PRODUCT_LIST="MATLAB Simulink" \
3841
sudo python3 - \
3942
--admin admin_user:admin_password \
4043
--plugin tljh-matlab

install_guides/vscode/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Run MATLAB in Jupyter Notebooks Using VS Code
2+
3+
This guide shows how to run MATLAB® in Jupyter notebooks using Visual Studio® Code.
4+
5+
## Setup
6+
7+
1. Install [Jupyter Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter).
8+
9+
2. Install [MATLAB Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=MathWorks.language-matlab).
10+
11+
3. Install the [MATLAB Integration for Jupyter](https://github.com/mathworks/jupyter-matlab-proxy) packages in your desired [Python environment (VS Code)](https://code.visualstudio.com/docs/python/environments):
12+
13+
```bash
14+
python3 -m pip install jupyter-matlab-proxy
15+
install-matlab-kernelspec
16+
```
17+
18+
4. Install MATLAB using [MATLAB Package Manager](https://www.mathworks.com/help/install/ug/get-mpm-os-command-line.html). Ensure that MATLAB is available on the system PATH from where you started VS Code.
19+
20+
## Open a Jupyter Notebook and Select the MATLAB Kernel
21+
22+
1. Create a Jupyter Notebook by running the `Create: New Jupyter Notebook` command from the Command Palette (`Ctrl+Shift+P`) or by creating a new `.ipynb` file in your workspace.
23+
24+
2. To start a MATLAB Kernel in a notebook, click **Select Kernel**.
25+
26+
![Kernel picker](./img/kernel-picker.png)
27+
28+
3. Click **Jupyter Kernel**.
29+
30+
![Click on Jupyter Kernel](./img/click-on-jupyter-kernel.png)
31+
32+
4. Select a MATLAB Kernel from the list of kernels in your Python environments.
33+
34+
![Pick MATLAB Kernel](./img/pick-matlab-kernel.png)
35+
36+
5. You see the name of your selected MATLAB kernel on the top right.
37+
38+
![Selected Kernel](./img/selected-kernel.png)
39+
40+
For more general information about using Jupyter Notebooks in VS Code, see [Create or Open a Jupyter Notebook (VS Code)](https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook).
41+
42+
## Run Cells
43+
44+
To run a cell, click the **Run** button to the left.
45+
46+
![Click to Run Cell](./img/play-button.png)
47+
48+
The output of your code is displayed below.
49+
50+
![Using MATLAB in Jupyter Notebook VSCode](./img/matlab.png)
51+
52+
53+
----
54+
55+
Copyright 2025 The MathWorks, Inc.
56+
57+
----
Loading
28 KB
Loading

install_guides/vscode/img/matlab.png

127 KB
Loading
Loading
7.6 KB
Loading
25.3 KB
Loading

0 commit comments

Comments
 (0)