Skip to main content

A Matlab kernel for Jupyter

Prerequisites

Install Jupyter Notebook and the Matlab engine for Python.

Installation

Install using:

$ pip install matlab_kernel

or pip install git+https://github.com/Calysto/matlab_kernel for the dev version.

To use the kernel, run one of:

$ jupyter notebook
# In the notebook interface, select Matlab from the 'New' menu
$ jupyter qtconsole --kernel matlab
$ jupyter console --kernel matlab

To remove from kernel listings:

$ jupyter kernelspec remove matlab

Configuration

The kernel can be configured by adding an matlab_kernel_config.py file to the jupyter config path. The MatlabKernel class offers plot_settings as a configurable traits. The available plot settings are: ‘format’, ‘backend’, ‘width’, ‘height’, and ‘resolution’.

cat ~/.jupyter/matlab_kernel_config.py
c.MatlabKernel.plot_settings = dict(format='svg')

Troubleshooting

Kernel Times Out While Starting

If the kernel is not starting, try running the following from a terminal.

python -m matlab_kernel.check

Please include that output if opening an issue.

Kernel is Not Listed

If the kernel is not listed as an available kernel, first try the following command:

python -m matlab_kernel install --user

If the kernel is still not listed, verify that the following point to the same version of python:

which python  # use "where" if using cmd.exe
which jupyter

Additional information

The Matlab kernel is based on MetaKernel, which means it features a standard set of magics. For a full list of magics, run %lsmagic in a cell.

A sample notebook is available online.

A note about plotting. After each call to Matlab, we ask Matlab to save any open figures to image files whose format and resolution are defined using the %plot magic. The resulting image is shown inline in the notebook. You can use %plot native to raise normal Matlab windows instead.

Advanced Installation Notes

We automatically install a Jupyter kernelspec when installing the python package. This location can be found using jupyter kernelspec list. If the default location is not desired, you can remove the directory for the octave kernel, and install using python -m matlab_kernel install. See python -m matlab_kernel install --help for available options.

It has been reported that Matlab version 2016b works fine. However, Matlab 2014b does not work with Python 3.5.

Development

Install the package locally:

$ pip install -e .
$ python -m matlab_kernel install

As you make changes, test them in a notebook (restart the kernel between changes).

Metadata

Release files for matlab-kernel 0.17.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matlab-kernel 0.17.1
File Size Uploaded
matlab_kernel-0.17.1.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matlab-kernel 0.17.1
File Interpreter ABI Platform
matlab_kernel-0.17.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / matlab_kernel-0.17.1.tar.gz

Download URL matlab_kernel-0.17.1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a232b9293b7d7773cf760d925f760fc34d96af0796236eb27a84166edaa03f98
BLAKE2b-256 checksum
How to use checksums
7c33cc16cbf7e3890d7cb88a88a6c3ab363d73742d0ba87d3eacff86c39ca766
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / matlab_kernel-0.17.1-py3-none-any.whl

Download URL matlab_kernel-0.17.1-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5e95e17bb3c37bffe47625e81593adaa2fc191a91f4aed5d2f23be7b5a40375
BLAKE2b-256 checksum
How to use checksums
76eaca65cc2cbc3afbeabaef70073a558afb62dc3bc16db0b1009225f087186b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.17.1 This release

2 release files

0.17.0

2 release files

0.16.7

2 release files

0.16.5

2 release files

0.16.4

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.1

2 release files

0.15.0

2 release files

0.14.3

2 release files

0.14.2

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.4

2 release files

0.13.3

2 release files

0.13.0

1 release file

0.12.0

1 release file

0.11.0

1 release file

0.10.2

1 release file

0.10.1

1 release file

0.10.0

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.10

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3.1

2 release files

0.3

2 release files

0.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page