Main Content

matlab::engine::connectMATLAB

Connect to sharedMATLABsession synchronously

Description

std:: unique_ptr connectMATLAB()

std:: unique_ptr connectMATLAB(const matlab::engine::String& name)

Connect synchronously to a shared MATLAB®session on the local machine.

  • If you specify the name of a shared MATLAB session, but the engine cannot find a session with that name, the engine throws an exception.

  • If you do not specify a name and there is no shared MATLAB session available, the engine starts a new shared MATLAB session. The MATLAB desktop is not started.

  • If you do not specify a name and there are shared MATLAB sessions available, the engine connects to the first available session.

Include

Namespace:

matlab::engine
Include MatlabEngine.hpp

Parameters

const matlab::engine::String& name

Name of the shared MATLAB session

Return Value

std:: unique_ptr

Pointer to aMATLABEngineobject

Exceptions

matlab::engine::EngineException

Throws exception if function fails to connect to the specified MATLAB session.

Examples

expand all

Connect to a shared MATLAB session namedmy_matlab.

std:: unique_ptr matlabPrt = connectMATLAB(u"my_matlab");

Version History

Introduced in R2017b