Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

从 C 调用 MATLAB

使用 mxArray 从 C 程序中运行 MATLAB® 代码

注意

Engine API for C 中的函数支持 C Matrix API 中定义的 MATLAB mxArray 数据结构。要使用现代 C++ 功能编写应用程序,请参阅 从 C++ 调用 MATLAB

引擎应用程序是独立的程序,它们允许您从自己的 C/C++ 程序调用 MATLAB,从而将 MATLAB 用作计算引擎。要编译引擎应用程序,请调用 mex 函数。

引擎应用程序需要已安装版本的 MATLAB;您无法在只有 MATLAB Runtime 的机器上运行 MATLAB Engine。

Engine API for C

EngineType for MATLAB engine
engOpenStart MATLAB engine session
engOpenSingleUseStart MATLAB engine session for single, nonshared use
engCloseQuit MATLAB engine session
engEvalStringEvaluate expression in string
engGetVariableCopy variable from MATLAB engine workspace
engPutVariablePut variable into MATLAB engine workspace
engGetVisibleDetermine visibility of MATLAB engine session
engSetVisibleShow or hide MATLAB engine session
engOutputBufferSpecify buffer for MATLAB output

主题

编写引擎应用程序

编译和运行 Windows 应用程序

编译和运行 Mac 应用程序

编译和运行 Linux 应用程序

在集成开发环境中编译

疑难解答

Can't Start MATLAB Engine

What to do when MATLAB engine does not run.

Debug MATLAB Function Called by C Engine

How to verify MATLAB functions used in engine applications.

User Input Not Supported

Some MATLAB functions that interact with the user are not supported in engine applications.

Multithreaded Applications

MATLAB libraries are not thread-safe.