Main Content

本页对应的英文页面已更新,但尚未翻译。 若要查看最新内容,请点击此处访问英文页面。

用于 C++ 的 MATLAB 引擎 API

从支持面向对象编程和异步执行的 C++ 程序运行 MATLAB® 代码。

用于 C++ 的 MATLAB 引擎 API 提供 C++ 编程语言与 MATLAB 之间的接口。此 API 使 C++ 程序能够启动 MATLAB、计算带参数的 MATLAB 函数,并在 MATLAB 和 C++ 程序之间交换数据。

用于 C++ 的 MATLAB 引擎 API 支持 MATLAB 数据 API,这样,在 MATLAB 外部运行的应用程序可通过独立于 MATLAB 的接口处理 MATLAB 数据。有关 MATLAB 数据 API 的详细信息,请参阅 MATLAB 数据 API

共享 MATLAB 会话

matlab.engine.shareEngine将正在运行的 MATLAB 会话转换为共享会话

启动、查找、连接和终止 MATLAB

matlab::engine::connectMATLABConnect to shared MATLAB session synchronously
matlab::engine::connectMATLABAsyncConnect to shared MATLAB session asynchronously
matlab::engine::findMATLABFind shared MATLAB sessions synchronously
matlab::engine::findMATLABAsyncFind shared MATLAB sessions asynchronously
matlab::engine::startMATLABStart MATLAB synchronously
matlab::engine::startMATLABAsyncStart MATLAB asynchronously
matlab::engine::terminateEngineClientFree engine resources during runtime

类型转换

matlab::engine::convertUTF8StringToUTF16StringConvert UTF-8 string to UTF-16 string
matlab::engine::convertUTF16StringToUTF8StringConvert UTF-16 string to UTF-8 string

类型定义

matlab::engine::StreamBuffer Define stream buffer
matlab::engine::String Define UTF16 string

matlab::engine::MATLABEngineEvaluate MATLAB functions from C++ program
matlab::engine::FutureResultRetrieve result from asynchronous operation
matlab::engine::SharedFutureResult Retrieve result from asynchronous operation as shared future
matlab::engine::WorkspaceTypeType of MATLAB workspace

主题

设置和编译引擎应用程序

Introduction to Engine API for C++

Introduction to the basic design of a C++ engine program.

编译 C++ 引擎程序

在不同平台上编译引擎应用程序。

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 matlab::engine namespace.

启动和连接到 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.

调用函数和交换数据

从 C++ 调用 MATLAB 函数

从 C++ 调用 MATLAB 函数,从而将变量传递给 MATLAB 并将变量返回给 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™.

创建 MATLAB 数据类型

Create Structure Arrays from C++

Create a structure array in C++ and pass it to MATLABor 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.