creating a 3D mwArray for a mcr shared library

2 次查看(过去 30 天)
Hello together,
I have a Matlab function
res = hogCellsForVolume(data)
that takes a 3dimensional double Array "data" with a size of (a,b,c) as input and returns a 4 dimensional double array res with a size of (20,a,b,c).
I created a C++ shared library with the MATLAB compiler, which seemed to have worked. (I successfully created a "helloWorld" example shared library that takes a double as input and which I could call from my c++ file)
I initialize MATLAB like this:
if
(!mclInitializeApplication(NULL,0))
{
std::cerr << "Could not initialize the application properly."
<< std::endl;
}
if( !hogCellsForVolumeInitialize())
{
std::cerr << "Could not initialize the library properly."
<< std::endl;
}
std::cout << "init done."<< std::endl;
I already learned that I cannot directly create a 3dim mwArray, but that it should be possible to create a 1d Array and then reshape it later.
But I cannot seem to get it to work. I found this example:
double data[] = {1,4,2,5,3,6};
mwArray C(2, 3, data); // matrix constructor
Which won't compile:
/home/maid/phd/trunk/lmbscripts/scr_mcrtest.cc:78:23: error: no matching function for call to 'mwArray::mwArray(int, int, double [6])'
/home/maid/phd/trunk/lmbscripts/scr_mcrtest.cc:78:23: note: candidates are:
/misc/software-lin/matlabR2013a/extern/include/mclcppclass.h:242:5: note: mwArray::mwArray(array_ref*, bool)
...
and about 3 pages more of candidates, that I skipped here.
An mwArray from a double worked for me:
mwArray in(2);
Can somebody point me in the right direction for this?
I'm on Ubuntu 12.04 with MATLAB R2013a.
Best regards, Dominic

回答(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