After using R notebooks for a while I found it really unintuitive to use MATLAB in IDE. I read that it’s possible to use MATLAB with IPython but the instructions seemed a bit out of date. When I tried to follow them, I still could not run MATLAB with Jupyter (spin-off from IPython).
I wanted to conduct analyses of electroencephalographic (EEG) activity and the best plug-ins to do it (EEGLAB and ERPLAB) were written in MATLAB. I still wanted to use a programming notebook so I had to combine Jupyter and MATLAB.
I spent a bit of time setting it all up so I thought it might be worthwhile to share the process. Initially, I had three version of MATLAB (2011a, 2011b, and 2016b) and two versions of Python (2.7 and 3.3). This did not make my life easier of Windows 7.
Eventually, I only kept the installation of MATLAB 2016b to avoid problems with paths pointing to other versions. MATLAB’s Python engine works only with MATLAB 2014b or later so keeping the older versions could only cause problems.
pip install metakernel
pip install matlab_kernel– this will use the development version of the MATLAB kernel.
pip install pymatbridgeto install a connector between Python and MATLAB.
MATLAB should now be available in the list of available languages.
Once you choose it, you can start using it in a Jupyter notebook:
Obviously, thing were not always this smooth. Initially, I ran into problems with installing MATLAB’s Python engine. The official website suggested running the following code:
python setup.py install
Which I did but it resulted in an error:
Luckily, the error message was clear so I had to point Python to run the 64-bit version. I double-checked my versions with:
Which returned 64-bit as expected:
Using a command with full path to Python solved the problem:
I hope this will be useful. I have been messing with other issues which were pretty specific to my system so I did not include them here. Hopefully, these instructions will be enough to make MATLAB work with Jupyter.
PS: I have also explained how to use MATLAB with Jupyter on Ubuntu.