Skip to content

Matlab notebooks in Jupyther

by aizzet on December 29th, 2017

Something really neat with Python are the iPython Notebooks, now called Jupyther. Matlab has also created its own live scripts, but you find it more suitable to use Matlab scripting within Jupyther notebooks.
Here is the How-to install instructions on Mac OS X (I have High Sierra). For Windows and Ubuntu installs, you may want to respectively look here and on there.

  1. First, you want to make sure that Python is installed. To do so, just run python --version in your Terminal.
  2. If Python is not installed, do so by downloading and installing Anaconda. I personally installed Python 2.7
  3. In Matlab, run matlabroot in the command window. This provides you the path to your matlab version.
  4. In the terminal, run cd "matlabroot/extern/engines/python" python setup.py install. Note that here you need to replace matlabroot by the path provided by Matlab previously on step 3.
  5. Then, run cd in the Terminal to go back to your home directory (where Anaconda should be installed) and run the following:
    pip install pymatbridge
    pip install matlab_kernel
    python -m matlab_kernel install
  6. Point the kernel to your own version of Matlab by typing in the Terminal: echo “export MATLAB_EXECUTABLE=/Applications/MATLAB_2017b.app/bin/matlab” >> ~/.bash_profile.
  7. Last, restart your Terminal or reload your .bash_profile. To do so, type source .bash_profile in the Terminal.
  8. Your are now good to go! To use Jupyther with Matlab, just run ipython notebook in the Terminal. A Jupyther window will open. Simply click New and select Matlab to start a new Matlab notebook.

Please do not hesitate to check the following webpages where I found most of the info, and also to add a comment.

Webliography:
• MathWorks: Install MATLAB Engine API for Python.
• Anne Urai webpage.
• Eryk Walczak blog: install on Windows and on Linux (Ubuntu).

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS