设置:
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;
<stdio.h><stdlib.h><conio.h>"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;
symbian有自己的一套库。要好的成型的C代码,比如前两天为了解析XML我引用到的tinyxml。所以在symbian下引用C标准库就非常重要,这是对以前代码非常好的移植方式。
为了能用C标准库,主要修改mmp文件中的路径和库配置。添加如下两行,就可以用C标准库了。
SYSTEMINCLUDE /epoc32/include/stdapis
LIBRARY ......