matlab引擎调用问题
程序的目的是调用matlab的fsolve函数求解非线性方程。为什么我这样书写,结果输出全是零。代码在matlab下编译正确。请指教一下问题所在。double xa;
Engine *ep;
if (!(ep=engOpen(NULL))) {
cout <<"Can't start Matlab engine!" <<endl;
exit(1);
}
mxArray *xy=mxCreateDoubleMatrix(1,10,mxREAL);
engEvalString(ep,"y=inline('','x');");
engEvalString(ep,"x0=;");
engEvalString(ep,"=fsolve(y,x0,optimset('fsolve'))");
engGetVariable(ep,"xy");
memcpy(xa,mxGetPr(xy),10*sizeof(double));
for(int k=0;k<10;k++)
printf("xa[%d]=%f\n",k+1,xa);
engClose(ep);
页:
[1]