The MATLAB® Engine API for C++ comprises functions, classes, and typedefs in matlab::engine
namespace. This API supports the MATLAB Data API, which provides a way for applications running outside of MATLAB to work with MATLAB data through a MATLAB-neutral interface. For more information on the MATLAB Data API, see MATLAB Data API.
Function | Purpose |
---|---|
matlab::engine::startMATLAB | Start a MATLAB session |
matlab::engine::startMATLABAsync | Start a MATLAB session asynchronously |
matlab::engine::connectMATLAB | Connect to a shared MATLAB session on the local machine using the specified name. |
matlab::engine::connectMATLABAsync | Connect to a shared MATLAB session on the local machine using the specified name asynchronously. |
matlab::engine::findMATLAB | Find all shared MATLAB sessions from the local machine. |
matlab::engine::findMATLABAsync | Find all shared MATLAB sessions from the local machine asynchronously. |
matlab::engine::convertUTF8StringToUTF16String | Convert UTF-8 string to UTF-16 string. |
matlab::engine::convertUTF16StringToUTF8String | Convert UTF-16 string to UTF-8 string. |
matlab::engine::terminateEngineClient | Free engine resources during runtime |
Class | Purpose |
---|---|
matlab::engine::MATLABEngine | Use to execute MATLAB functions from C++. |
matlab::engine::FutureResult | Retrieve results from asynchronous operations. |
matlab::engine::WorkspaceType | Enumeration class defining MATLAB workspace as BASE or GLOBAL |
The matlab::engine::MATLABEngine
class defines the following member functions.
Member Function | Purpose |
---|---|
feval | Evaluate a MATLAB® function with arguments synchronously. |
fevalAsync | Evaluate a MATLAB® function with arguments asynchronously. |
eval | Evaluate a MATLAB® statement synchronously. |
evalAsync | Evaluate a MATLAB® statement asynchronously. |
getVariable | Get a variable from the MATLAB® base or global workspace synchronously. |
getVariableAsync | Get a variable from the MATLAB® base or global workspace asynchronously. |
setVariable | Put a variable into the MATLAB® base or global workspace synchronously. |
setVariableAsync | Put a variable into the MATLAB® base or global workspace asynchronously. |
getProperty | Get an object property value. |
getPropertyAsync | Get an object property value asynchronously. |
setProperty | Set an object property value. |
setPropertyAsync | Set an object property value asynchronously. |
Exception | Cause |
---|---|
| Base class of all C++ Engine exceptions. |
| There is a MATLAB runtime error in function or MATLAB fails to start. |
| The MATLAB session is not available |
| There is a syntax error in the MATLAB function. |
| There is a MATLAB runtime error in the MATLAB function or statement. |
| Evaluation of the MATLAB function is canceled. |
| Thrown by matlab::engine::FutureResult::get if the evaluation of the MATLAB function or statement is interrupted. |
| The result of the MATLAB function cannot be converted to the specified type |
The size of data arrays passed between C++ and MATLAB is limited to 2 GB. This limit applies to the data plus supporting information passed between the processes.
The MATLAB Engine for C++ is safe to use in a multiple-thread environment. You can make these connections to shared MATLAB sessions:
Connect to different shared MATLAB sessions from separate threads of a C++ application.
Connect to a single MATLAB session from multiple engine applications.
You cannot use multiple threads of the same process to connect to a single shared MATLAB session.