主要内容

Python 中调用 MATLAB

编写可用于 MATLAB® 的 Python® 程序

MATLAB Engine API for Python 可提供一个包,供 Python 将 MATLAB 作为计算引擎来调用。该引擎支持参考实现 (CPython)。有关支持的版本信息,请参阅 MATLAB 产品(按版本)兼容的 Python 版本

引擎应用程序需要已安装版本的 MATLAB;您无法在只有 MATLAB Runtime 的机器上运行 MATLAB Engine。

函数

全部展开

matlab.engine.start_matlab启动 MATLAB Engine for Python
matlab.engine.find_matlab查找共享的 MATLAB 会话以连接到用于 PythonMATLAB 引擎
matlab.engine.connect_matlab将共享 MATLAB 会话连接到用于 PythonMATLAB 引擎
matlab.engine.shareEngine将正在运行的 MATLAB 会话转换为共享会话
matlab.engine.engineName返回共享 MATLAB 会话的名称
matlab.engine.isEngineShared确定 MATLAB 会话是否共享

全部展开

matlab.engine.MatlabEnginePython 对象使用 MATLAB 作为 Python 会话中的计算引擎
matlab.engine.FutureResult存储在 Python 对象中的 MATLAB 函数异步调用的结果

主题

安装

  • 安装用于 Python 的 MATLAB Engine API
    MATLAB Engine API for Python 允许您从 Python 环境中调用 MATLAB 函数并执行 MATLAB 命令。要使用 MATLAB 引擎,您必须在计算机上安装受支持的 Python 版本,并且必须将 MATLAB Engine API for Python 作为 Python 包安装。

快速入门

会话管理

使用 MATLAB 工作区

数据交换和映射

调用 MATLAB 函数

疑难解答

MATLAB Engine API for Python 的限制

MATLAB Engine API for Python 不支持以下功能。

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.