how to save data into and get data out of mwArray?

2 次查看(过去 30 天)
I recently compiled a m code into a C++ shared library for the first time. I am trying to call this Matlab-generated code in my C++ project. Then I found this mwArray type which I have zero experience.
_declspec (dllexport) void contourcGenerate(double *c, double *image2DArray, int imageWidth, int imageHeight, double contourLevel)
{
// Must declare all MATLAB data types after initializing the
// application and the library, or their constructors will fail.
mwArray im(1,imageWidth*imageHeight,mxDOUBLE_CLASS);
mwArray a(1,1,mxDOUBLE_CLASS);
mwArray result;
//create the input data
im.SetData(image2DArray,imageWidth*imageHeight);
a.SetData(&contourLevel,1);
// call matlab-generated code
generateContour(1, result,im,a,a);
//Get data out
result.GetData(c,150);
}
It errors out when calling 'generateContour'. Here is the error code
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: MathWorks::mcl::mclUserException at memory location 0x0018F12C.
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: MathWorks::mcl::mclUserException at memory location 0x0018F12C.
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: NullPointerException at memory location 0x0018F27C.
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: NullPointerException at memory location 0x0018F27C.
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: mwException at memory location 0x0018F2D8.
  • First-chance exception at 0x7533C41F: Microsoft C++ exception: mwException at memory location 0x0018F2D8.
  • Unhandled exception at at 0x7533C41F: Microsoft C++ exception: mwException at memory location 0x0018F2D8.
I don't know whether this is because I did not use those mwArrays correctly. HELP PLZ.
  2 个评论
Jan
Jan 2013-7-26
"it did not work, some memory leak issue" is not precise enough. Please provide all information you know to make answering as easy as possible. Thanks.
Xiaolei Hu
Xiaolei Hu 2013-7-26
I just pasted all the errors into the post. Hopefully that's helpful. Thanks.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deploy to C++ Applications Using mwArray API (C++03) 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by