MATLAB: Converting std::vector type to mwArray

cMATLAB Compilermwarrayshared library

Hello,
I am trying to pass a vector in C++ to a C++ share library matlab function compiled by Matlab Compiler.
I am trying to convert a vector, for example myvect, to the mwArray type so that by matlab function can use it. The myvect has the following format in C++,
vector<double> myvect;
How can I convert this into mwArray type?
Thank you.

Best Answer

mwArray a(1, myvect.size(), mxDOUBLE_CLASS);
a.SetData(&myvect[0], myvect.size());