Installing Jupyter for Matlab#
This guide assumes you have Matlab already installed. I’ll be assuming you have Matlab R2019_b installed.
To use Jupyter notebooks with Matlab, you need to install Jupyter (which relies on Python) and the Matlab engine for Python.
macOS/Linux#
I recommend you install Anaconda to manage your Python environment—it makes installing and managing packages very easy. This comes with the Jupyter notebook.
Create and activate an environment called
jmatlab
for Jupyter with Python 3.7:
$ conda create -vv -n jmatlab python=3.7 jupyter
$ conda activate jmatlab
Before the second command, you may need to tell your shell (e.g., bash, zsh) about conda, by doing conda init zsh
for example. If you get an error with the conda activate
command, your terminal should tell you to do this.
You should activate this environment whenever you want to run Jupyter.
Install the Matlab kernel for Jupyter:
$ pip install matlab_kernel
Install the Python engine for Matlab:
$ cd /Applications/MATLAB_R2019b.app/extern/engines/python
$ python setup.py install
If you are using a different version of Matlab, then that path will be different.
Run Jupyter notebook:
$ jupyter notebook
and create a new Matlab notebook with “New” then “Matlab” under “Notebook:”.
Windows#
Open the Anaconda Prompt
(to be continued)
Try it out#
Now try it out:
disp('This is running Matlab!')
This is running Matlab!