我希望能够从C++传递一个字符串向量到MATLAB。我已经尝试使用可用的函数,例如
因此,我有这样的东西:
问题是如何将这个向量传输到matlab环境中?
mxCreateCharMatrixFromStrings
,但它并没有给我正确的行为。因此,我有这样的东西:
void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
vector<string> stringVector;
stringVector.push_back("string 1");
stringVector.push_back("string 2");
//etc...
问题是如何将这个向量传输到matlab环境中?
plhs[0] = ???
我的目标是能够运行:
>> [strings] = MyFunc(...)
>> strings(1) = 'string 1'
mxDuplicateArray
?如果你使用mxSetCell(arr, i, str);
,你也可以移除mxDestroyArray(str);
。 - Cris Luengo