Main Content

CallMATLABfromPython

Write Python®programs that work with MATLAB®

The MATLAB Engine API for Python provides a package for Python to call MATLAB as a computational engine. The engine supports the reference implementation (CPython).For supported version information, seeVersions of Python Compatible with MATLAB Products by Release.

Engine applications require an installed version of MATLAB; you cannot run the MATLAB engine on a machine that only has the MATLAB Runtime.

Functions

expand all

matlab.engine.start_matlab StartMATLABEngine forPython
matlab.engine.find_matlab Find sharedMATLABsessions to connect toMATLABEngine forPython
matlab.engine.connect_matlab Connect sharedMATLABsession toMATLABEngine forPython
matlab.engine.shareEngine Convert runningMATLABsession to shared session
matlab.engine.engineName Return name of sharedMATLABsession
matlab.engine.isEngineShared Determine ifMATLABsession is shared

Classes

expand all

matlab.engine.MatlabEngine Pythonobject usingMATLABas computational engine withinPythonsession
matlab.engine.FutureResult Results of asynchronous call toMATLABfunction stored inPythonobject

Topics

Installing

开始

Session Management

Using MATLAB Workspace

Data Exchange and Mapping

Calling MATLAB Functions

Troubleshooting

Limitations to MATLAB Engine API for Python

The MATLAB Engine API does not support these features.

Troubleshoot MATLAB Errors in Python

When a MATLAB function raises an error, the MATLAB Engine for Python stops the function and catches the exception raised by MATLAB.