登录论坛

查看完整版本 : [MATLAB混合编程] 一个画图的简单实现在vc6.0下正常在vs2008下异常


nikistone
2012-02-13, 15:28
#include "stdafx.h"
#include "engine.h"
#include "math.h"
#include <iostream>
using namespace std;

#pragma comment(lib,"ws2_32.lib")

int main(int argc, char* argv[])
{

Engine *ep = engOpen(NULL);
if(!ep)
{
cout<<"engine open fail"<<endl;
return -1;
}
const int N = 4;
double x[N],y[N];

x[0] = 57;
x[1] = 234;
x[2] = 135;
x[3] = 77;

mxArray *xx = mxCreateDoubleMatrix(1,N,mxREAL);
mxArray *yy = mxCreateDoubleMatrix(1,N,mxREAL);

memcpy(mxGetPr(xx),x,N*sizeof(double));
memcpy(mxGetPr(yy),y,N*sizeof(double));

engPutVariable(ep,"xx",xx);
engPutVariable(ep,"yy",yy);

engEvalString(ep,"rectangle('Position',xx)");
getchar();
mxDestroyArray(xx);
mxDestroyArray(yy);
getchar();
engClose(ep);

return 0;
}

实现类似功能,在vc6.0下是正常的,在vs2008下给出如下异常:
main.exe 中的 0x7c812afb 处未处理的异常: Microsoft C++ 异常: 内存位置 0x0012f8ec 处的 MathWorks::System::SimpleException。
请问这个问题如何解决?