Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error while calling matlab 7.0.1 from visual c++ 6.0

Status
Not open for further replies.

cocla2

Computer
Mar 7, 2007
1
I've included the "engine.h", and there is no problem while compiling. But when I execute the code, a first chance exception is ouccured while excuting "ar = mxGetPr(mp);"

The error is:
First-chance exception in CameraTest.exe (LIBMX.DLL): 0xC0000005: Access Violation

Can anyone help me? Your help will be very appreciated.
The source code is:
---------------------------------------
Engine *ep;
Engine *ep;
mxArray *mp, *ans;
double *ar, *detreal;
int i,j;
mp = mxCreateDoubleMatrix(3,3,mxREAL);
ar = mxGetPr(mp);
for (i=0; i<3; i++)
for (j=0; j<3; j++) {
*ar=1;
ar++;
}

ep = engOpen("");
engPutVariable(ep, "T", mp);
engEvalString(ep,"d = sum(sum(T));");
ans=engGetVariable(ep,"d");
detreal=mxGetPr(ans);
engClose(ep);
------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor