Package: jupyter-matlab-proxy
MATLAB Integrationfor JupyterRun MATLAB® code in Jupyter® environments such as Jupyter notebooks, JupyterLab, and JupyterHub.Table of ContentsFeatures of MATLAB Integrationfor JupyterRequirementsInstallGet StartedRun MATLAB Code in a Jupyter NotebookOpen MATLAB in a BrowserEdit MATLAB Files in JupyterLabLimitationsFeatures of MATLAB Integrationfor JupyterYou can use this package to run MATLAB code in Jupyter notebooks and JupyterLab.From your Jupyter notebook or JupyterLab, you can also open the MATLAB development environment in your browser to access more MATLAB features.RequirementsSupported operating systems:Linux®MacOSWindows® (supported fromv0.6.0).Python versions: 3.8 | 3.9 | 3.10 | 3.11MATLAB R2020b or later, installed and on the system PATH.# Confirm MATLAB is on the PATHwhichmatlabNote: You only need MATLAB installed if you want to execute MATLAB code. You can open Jupyter notebooks containing MATLAB code without having MATLAB installed.System dependencies required to run MATLAB:TheMATLAB Dependenciesrepository containsbase-dependencies.txtfiles that list the libraries required to run each release of MATLAB on a given operating system. To see how to use these files, refer to the Dockerfiles in the same folder.Linux based systems also requireX Virtual Frame Buffer (Xvfb), which you can install with:# On a Debian/Ubuntu based system:$sudoaptinstallxvfb# On a RHEL based system:$yumsearchXvfb
xorg-x11-server-Xvfb.x86_64:AXWindowsSystemvirtualframebufferXserver.
$sudoyuminstallxorg-x11-server-XvfbInstallInstall this Python package from the Python Package Index (PyPI) or build it from the source.Install from PyPIpython-mpipinstalljupyter-matlab-proxyInstalling this package will not install MATLAB. To execute MATLAB code in Jupyter, you must haveMATLAB installedseparately.Build from SourceAlternatively, you can install this package by building it from the source. This requires Node.js® version 16 or higher. To install Node.js, seeNode.js Downloads.gitclonehttps://github.com/mathworks/jupyter-matlab-proxy.gitcdjupyter-matlab-proxy
python-mpipinstall.Integration with JupyterHubTo use MATLAB with JupyterHub, install thejupyter-matlab-proxyPython 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 forUsing MATLAB Integrationfor Jupyterin a Docker Container.Using SimulinkThis package lets you use Simulink® programmatically by entering commands in a Jupyter notebook. To view a model or use other Simulink features that require the Simulink UI, you can use a VNC to connect your Jupyter environment to a Linux desktop where you have MATLAB and Simulink installed. For instructions, seeMATLAB Jupyter VNC Solution.TroubleshootingTo troubleshoot package installation issues, seeTroubleshooting.Get StartedThis section shows you how to:Run MATLAB Code in a Jupyter NotebookOpen MATLAB in a BrowserEdit MATLAB files in JupyterLabInstall Jupyter Notebook or JupyterLab:# For Jupyter Notebookpython-mpipinstallnotebook# For JupyterLab 3python-mpipinstall'jupyterlab>=3.0.0,<4.0.0a0'Note: the package allows you to execute MATLAB code in both JupyterLab 3 and JupyterLab 4, but syntax highlighting and auto indentation are currently only supported on JupyterLab 3. To upgrade to JupyterLab 4, runpython -m pip install --upgrade jupyterlab.Open your Jupyter environment by starting Jupyter Notebook or JupyterLab.# For Jupyter Notebookjupyternotebook# For JupyterLabjupyterlabIf you are prompted for a token, click the link shown in your terminal to access your Jupyter environment.After installing this package, you see new MATLAB options in your Jupyter environments.Classic Notebook InterfaceJupyterLabRun MATLAB Code in a Jupyter NotebookTo open a Jupyter notebook where you can run MATLAB code, clickMATLAB Kernelin your notebook or JupyterLab.Classic Notebook InterfaceJupyterLabThis opens a Jupyter notebook that supports MATLAB.When you execute MATLAB code in a notebook for the first time, enter your MATLAB license information in the dialog box that appears. SeeLicensingfor details. The MATLAB session can take a few minutes to start.Multiple notebooks running on a Jupyter server share the underlying MATLAB process, so executing code in one notebook affects the workspace in others. If you work in several notebooks simultaneously, be aware that they share a workspace.With MATLAB R2022b and later, you can define a local function at the end of the cell where you want to call it:For technical details about how the MATLAB kernel works, seeMATLAB Kernel for Jupyter.Open MATLAB in a BrowserTo access more MATLAB features, you can open the MATLAB development environment in your browser. Click theOpen MATLABbutton in your notebook or JupyterLab.Classic Notebook InterfaceJupyterLabNotebooks in JupyterLab also have aOpen MATLABbutton on the toolbar:ClickingOpen MATLABopens the MATLAB development environment in a new browser tab.When you use the package for the first time, enter your MATLAB license information in the dialog box that appears. SeeLicensingfor details.For technical details about this MATLAB development environment, seeMATLAB in a Browser.Edit MATLAB Files in JupyterLabYou can also edit MATLAB.mfiles in JupyterLab. Click theMATLAB Filebutton.This opens an untitled.mfile where you can write MATLAB code with syntax highlighting and auto indentation.Currently, this package allows you to edit MATLAB.mfiles but not to execute them.To open a new MATLAB.mfile, you can also use the JupyterLab command palette. PressCTRL+SHIFT+C, then typeNew MATLAB Fileand pressEnter.LimitationsThis package has limitations. For example, it does not support certain MATLAB commands. For details, seeLimitations.To discuss a technical issue or submit an enhancement request,create a GitHub issue, or send an email tojupyter-support@mathworks.com.Copyright 2021-2024 The MathWorks, Inc.