我想将字符串向量从 C++ 传递给 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'