Main Content

matlab::engine::startMATLAB

Start MATLAB synchronously

Description

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

Start MATLAB® synchronously in a separate process with optional MATLAB startup options.

Include

Namespace:

matlab::engine
IncludeMatlabEngine.hpp

Parameters

const std::vector<String>& options

Options used to start MATLAB. You can specify multiple startup options. The engine supports all MATLAB startup options, except for the options listed in Unsupported Startup Options. For a list of options, see the platform-specific command matlab (Windows), matlab (macOS), or matlab (Linux).

Return Value

std::unique_ptr<MATLABEngine>

Pointer to the MATLABEngine object

Exceptions

matlab::engine::EngineException

MATLAB failed to start.

Examples

expand all

Start MATLAB synchronously and return a unique pointer to the MATLABEngine object.

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

Start MATLAB with the -nojvm option and return a unique pointer to the MATLABEngine object.

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