Main Content

matlab::engine::startMATLAB

同步启动 MATLAB

描述

std::unique_ptr<MATLABEngine> startMATLAB(const std::vector<String>& options = std::vector<String>())

使用可选的 MATLAB® 启动选项在单独进程中同步启动 MATLAB。

包括:

命名空间:

matlab::engine
包括:MatlabEngine.hpp

参数

const std::vector<String>& options

用于启动 MATLAB 的选项。您可以指定多个启动选项。该引擎支持所有 MATLAB 启动选项,但不支持的启动选项中列出的选项除外。有关选项列表,请参阅特定于平台的命令 matlab (Windows)matlab (macOS)matlab (Linux)

返回值

std::unique_ptr<MATLABEngine>

指向 MATLABEngine 对象的指针

异常

matlab::engine::EngineException

MATLAB 无法启动。

不支持的启动选项

该引擎不支持下列 MATLAB 启动选项:

  • -h

  • -help

  • -?

  • -n

  • -e

  • -softwareopengl

  • -logfile

有关 MATLAB 启动选项的信息,请参阅常用启动选项

示例

全部展开

同步启动 MATLAB,并返回指向 MATLABEngine 对象的唯一指针。

std::unique_ptr<MATLABEngine> matlabPtr = startMATLAB(); 
auto matlabApplication = matlab::engine::startMATLAB({u"-desktop"});

使用 -nojvm 选项启动 MATLAB,并返回指向 MATLABEngine 对象的唯一指针。

std::vector<String> optionVec;
optionVec.push_back(u"-nojvm");
std::unique_ptr<MATLABEngine> matlabPtr = startMATLAB(optionVec);

版本历史记录

在 R2017b 中推出