欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab 如何被c 调用函数调用函数调用,c 调用 matlab engine 自定义函数

发布时间:2025/10/17 循环神经网络 22 豆豆
生活随笔 收集整理的这篇文章主要介绍了 matlab 如何被c 调用函数调用函数调用,c 调用 matlab engine 自定义函数 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

设置:

1. Tools/Projects and Solutions/VC ++ Directories

Inlcude files: C:/Program Files/MATLAB/R2009a/extern/include

Library files: C:/Program Files/MATLAB/R2009a/extern/lib

2. Property

Configuration Properties/Linker

General: Additional Library Directories: "C:/Program Files/MATLAB/R2009a/extern/lib/win32/microsoft"

Input: Additional Dependencies: libmx.lib libmat.lib libeng.lib

#include

"stdafx.h"

#include

#include #include #include

fun_XY.m file

function Z = fun_XY(X,Y)

Z = X*Y;

"engine.h"

int

main(

int

argc,

char

**argv)

{

double

X[3][2] = {{1,4},{2,5},{3,6}};

double

Y[2][2] = {{1,2},{3,4}};

int

succeedNotFlag = 1;

Engine *ep;

if

(!(ep = engOpen(NULL)))

{

exit(1);

}

engSetVisible(ep,1);

mxArray *xx = mxCreateDoubleMatrix(3,2,mxREAL);

mxArray *yy = mxCreateDoubleMatrix(2,2,mxREAL);

memcpy(mxGetPr(xx),X,6*

sizeof

(

double

));

memcpy(mxGetPr(yy),Y,4*

sizeof

(

double

));

engPutVariable(ep,

"X"

,xx);

engPutVariable(ep,

"Y"

,yy);

int

rows = mxGetM(xx);

int

cols = mxGetN(xx);

succeedNotFlag = engEvalString(ep,"cd D://progX//CM//mt");

//succeedNotFlag = engEvalString(ep,"path(path,'D:/progX/CM/mt')"); //will not go to the right routine.

succeedNotFlag = engEvalString(ep,

"path(path,'D://progX//CM//mt')"

);

will go to the right routine.

succeedNotFlag = engEvalString(ep,

"Z = fun_XY_lan(X,Y);"

);

mxArray *z_ptr = NULL;

z_ptr = engGetVariable(ep,

"Z"

);

double

*z_c =

new

double

[6];

z_c = (

double

*) mxGetData(z_ptr);

mxDestroyArray(xx);

mxDestroyArray(yy);

delete

[]z_c;

engClose(ep);

return

0;

总结

以上是生活随笔为你收集整理的matlab 如何被c 调用函数调用函数调用,c 调用 matlab engine 自定义函数的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。