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

2 visualizaciones (últimos 30 días)
Xiaolei Hu
Xiaolei Hu el 26 de Jul. de 2013
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 comentarios
Jan
Jan el 26 de Jul. de 2013
"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 el 26 de Jul. de 2013
I just pasted all the errors into the post. Hopefully that's helpful. Thanks.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Deploy to C++ Applications Using mwArray API (C++03) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by