Call MATLAB from C++
The MATLAB Engine API for C++ provides an interface between the C++ programming language and MATLAB. This API enables C++ programs to launch MATLAB, evaluate MATLAB functions with arguments, and exchange data between MATLAB and C++ programs.
The MATLAB Engine API for C++ uses the MATLAB Data API for C++, which provides a way for applications running outside of MATLAB to work with MATLAB data through a MATLAB-neutral interface.
Share MATLAB Session
|Convert running MATLAB session to shared session|
Start, Find, Connect, and Terminate MATLAB
|Connect to shared MATLAB session synchronously|
|Connect to shared MATLAB session asynchronously|
|Find shared MATLAB sessions synchronously|
|Find shared MATLAB sessions asynchronously|
|Start MATLAB synchronously|
|Start MATLAB asynchronously|
|Free engine resources during runtime|
|Convert UTF-8 string to UTF-16 string|
|Convert UTF-16 string to UTF-8 string|
|Define stream buffer|
|Define UTF16 string|
|Evaluate MATLAB functions from C++ program|
|Retrieve result from asynchronous operation|
|Retrieve result from asynchronous operation as shared future|
|Type of MATLAB workspace|
Generate C++ Code Interface
|Generate C++ code interface for MATLAB packages, classes, and functions|
Setup and Build Engine Applications
- Introduction to Engine API for C++
Introduction to the basic design of a C++ engine program.
- Build C++ Engine Programs
Build engine applications on different platforms.
- Test Your Build Environment
Use this sample code to confirm your development environment for the MATLAB Engine API for C++.
- C++ Engine API
The MATLAB Engine C++ API comprises functions, classes, and typedefs in
Start and Connect to MATLAB
Call Functions and Exchange Data
- Call MATLAB Functions from C++
Call MATLAB functions from C++, passing variable to MATLAB and returning variables to C++.
- Evaluate MATLAB Statements from C++
Evaluate MATLAB expression from C++ and write variables into the MATLAB base workspace.
- Pass Variables from C++ to MATLAB
Pass variables from C++ to MATLAB as function arguments or by placing those variables directly in the MATLAB base workspace.
- Pass Variables from MATLAB to C++
Get variables from the MATLAB base or global workspace.
- Redirect MATLAB Command Window Output to C++
Redirect MATLAB command window output, including error messages, to you C++ program.
- Run Simulink Simulation from C++
Run Simulink® model simulations from C++ and visualize the results with MATLAB graphics.
- Convert C++ Engine Application to MATLAB Compiler SDK Application
How to convert an engine application to a deployed application using MATLAB Compiler SDK™.
Create MATLAB Data Types
- Create Structure Arrays from C++
Create a structure array in C++ and pass it to MATLAB or get a structure array defined in MATLAB.
- Create Cell Arrays from C++
Create heterogeneous arrays in C++ to use as MATLAB cell arrays.
- Pass Enumerations to MATLAB From C++
Pass enumeration members of MATLAB enumeration classes to MATLAB from C++.
- Pass Sparse Arrays to MATLAB From C++
Pass arrays to MATLAB as MATLAB sparse arrays.
Strongly Typed Interface
- What is Strongly Typed Interface for C++?
Learn how a C++ MATLAB Data API interface supports strongly typed MATLAB code.
- Write MATLAB Code for Strongly Typed Interface
How to write MATLAB code for a strongly typed C++ interface.
- Create C++ Header File from Strongly Typed MATLAB Function
Create a MATLAB Data API C++ header file from a strongly typed MATLAB function and integrate it with C++ application code that calls MATLAB.
- Data Type Mappings Between C++ and Strongly Typed MATLAB Code
Refer to data type mappings between C++ and MATLAB when using strongly typed MATLAB code.