Call MATLAB from C++
Run MATLAB® code from C++ programs, with object-oriented programming support and
asynchronous execution
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.
Topics
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 inmatlab::engine
namespace.
Start and Connect to MATLAB
- Start MATLAB Sessions from C++
Start and connect to a MATLAB session synchronously and asynchronously from C++. - Connect C++ to Running MATLAB Session
Connect the C++ engine to a MATLAB session that has been started as or converted to a shared session.
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.