主要内容

Python 获取 MATLAB 函数的帮助

如何查找 MATLAB 帮助

您可以从 Python® 访问所有 MATLAB® 函数的支持文档。此文档包括示例,并说明每个函数的输入参量、输出参量和调用语法。

MATLAB Engine API for Python 支持您使用 MATLAB 的 dochelp 函数。使用 doc 在系统 Web 浏览器中打开 MathWorks® 文档。在 Python 提示符下,使用 help 获取 MATLAB 函数的简要说明。

Python 中打开 MathWorks 文档

从 Python 中,您可以打开 MATLAB 函数参考页并搜索文档。

例如,显示 MATLAB plot 函数的参考页。(由于 doc 不返回输出参量,您必须设置 nargout=0。)

import matlab.engine
eng = matlab.engine.start_matlab()
eng.doc("plot",nargout=0)

参考页包括函数说明、示例和相关文档的链接。

注意

请点击示例标题,如果 MATLAB 参考页上未显示示例,请点击标题旁边的箭头。示例可以在页内折叠或展开。

如果不带位置参量调用 eng.doc,它将打开文档主页。(您仍须设置关键字参量 nargout=0。)

eng.doc(nargout=0)

要搜索 MATLAB 文档,请在文档中任意页顶部的搜索框中键入表达式。浏览器返回搜索结果列表,突出显示与表达式匹配的字词。

您也可以使用 docsearch 函数搜索文档。例如,搜索提及 plot 的页。

eng.docsearch("plot",nargout=0)

Python 提示符下显示 MATLAB 帮助

要在 Python 提示符下显示函数的帮助文本,请调用 MATLAB help 函数。例如,显示 erf 的帮助文本。

import matlab.engine
eng = matlab.engine.start_matlab()
eng.help("erf",nargout=0)
 ERF Error function.
    This MATLAB function returns the Error Function evaluated for each
    element of x.

    Syntax
      erf(x)

    Input Arguments
      x - Input
        real number | vector of real numbers | matrix of real numbers |
        multidimensional array of real numbers

    Examples
      Find Error Function
      Find Cumulative Distribution Function of Normal Distribution
      Calculate Solution of Heat Equation with Initial Condition

    See also erfc, erfcinv, erfcx, erfinv

    Introduced in MATLAB before R2006a
    Documentation for erf
    Other uses of erf

输出显示帮助文本,但不包括任何可能提到的其他 MATLAB 函数的帮助链接。