从 C++ 调用 MATLAB
从支持面向对象的编程和异步执行的 C++ 程序运行 MATLAB® 代码
MATLAB Engine API for C++ 提供 C++ 编程语言与 MATLAB 之间的接口。此 API 使 C++ 程序能够启动 MATLAB、计算带参量的 MATLAB 函数,并在 MATLAB 和 C++ 程序之间交换数据。支持的操作包括:
启动 MATLAB。
连接到本地计算机上的 MATLAB 共享会话。
使用从 C++ 传递的输入参量和从 MATLAB 函数返回的输出变量调用 MATLAB。
对 MATLAB 基础工作区中的 MATLAB 语句进行求值。
将变量从 C++ 传递给 MATLAB 和从 MATLAB 传递给 C++。
要快速入门,请参阅Set Up C++ Development Environment。
MATLAB Engine API for C++ 使用 MATLAB Data API for C++,这样,在 MATLAB 外部运行的应用程序可通过独立于语言的接口处理 MATLAB 数据。Engine API 还提供强定型接口,该接口在 MATLAB 和 C++ 之间强制执行严格的数据类型映射。您可以使用此强定型接口在 C++ 中通过其 MATLAB 名称调用 MATLAB 函数和类,就像它们是原生 C++ 函数和类一样。有关示例,请参阅Integrate Strongly Typed MATLAB Data in C++ Application。
类
函数
主题
要求
- Requirements to Build C++ Engine Applications
Install and configure a compiler and run-time environment so you can build C++ applications to call MATLAB. - Set Up C++ Development Environment
Set up a development environment to write C++ applications that call MATLAB functions.
在 C++ 中集成 MATLAB 代码
- Structure of C++ Engine Applications
Get started with the MATLAB Engine API for C++. - Integrate MATLAB Function in C++ Application
Create a C++ engine application using the MATLAB Engine and Data APIs. - Integrate Strongly Typed MATLAB Data in C++ Application
Use strongly typed data with the MATLAB Engine API for C++.
启动和连接到 MATLAB
- Start MATLAB Sessions from C++
How to start and connect to a MATLAB session synchronously or asynchronously from C++. - Connect C++ to Running MATLAB Session
How to connect a C++ application to a MATLAB session that was started as or converted to a shared session.
调用 MATLAB 函数
- 从 C++ 调用 MATLAB 函数
如何从 C++ 调用 MATLAB 函数,从而将变量传递给 MATLAB 并将变量返回给 C++。 - Evaluate MATLAB Statements from C++
How to evaluate MATLAB statements in your C++ program, and write variables to the MATLAB base workspace. - Pass Variables from C++ to MATLAB
How to pass variables from C++ to MATLAB as function arguments or by placing those variables directly into the MATLAB base workspace. - Pass Variables from MATLAB to C++
How to get variables from the MATLAB base or global workspace. - Redirect MATLAB Command Window Output to C++
How to redirect MATLAB Command Window output, including error messages, to your C++ program. - Convert C++ Engine Application to MATLAB Compiler SDK Application
Convert an engine application to a deployed application using MATLAB Compiler SDK™.
在 C++ 中使用 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. - Create Structure Arrays from C++
How to create structure arrays in C++ and pass them to MATLAB, or retrieve structure arrays from MATLAB. - Create Cell Arrays from C++
How to create heterogeneous arrays in C++ to use as MATLAB cell arrays. - Pass Enumerations to MATLAB from C++
How to pass members of a MATLAB enumeration class to MATLAB from C++. - Pass Sparse Arrays to MATLAB from C++
How to pass arrays from C++ to MATLAB as MATLAB sparse arrays. - Use MATLAB Handle Classes in C++
Integrate MATLAB handle classes with C++ applications. - Limitations of Strongly Typed Interface for C++
Strongly typed interface for C++ features not supported in MATLAB.