Main Content

从 C 应用程序中调用 MATLAB 函数

matlabroot/extern/examples/eng_mat 文件夹中的程序 engdemo.c 说明如何通过独立的 C 程序调用引擎函数。此示例使用 C Matrix API

注意

要从 C++ 应用程序调用 MATLAB® 函数,请使用 MATLAB Data API for C++。有关详细信息,请参阅从 C++ 调用 MATLAB 函数

对于该程序的 Microsoft® Windows® 版本,请打开 matlabroot\extern\examples\eng_mat 文件夹中的 engwindemo.c。对于 C++ 版本,请打开 engdemo.cpp

该程序的第一部分将启动 MATLAB 并向其发送数据。MATLAB 将分析数据并绘制结果图。

Plot from engdemo engine application.

程序继续运行:

Press Return to continue

Return 继续执行程序:

Done for Part I.
Enter a MATLAB command to evaluate.  This command should
create a variable X.  This program will then determine
what kind of variable you created.
For example: X = 1:5

输入 X = 17.5 继续执行程序。

X = 17.5
 
X =
 
   17.5000
 
 
Retrieving X...
X is class double
Done!

最后,程序释放内存,关闭 MATLAB 引擎,然后退出。

相关示例

详细信息