How to create a string array in matlab?
Posted
by aduric
on Stack Overflow
See other posts from Stack Overflow
or by aduric
Published on 2010-05-19T16:11:32Z
Indexed on
2010/05/19
16:30 UTC
Read the original article
Hit count: 262
I would like to pass a vector of strings from C++ to matlab. I have tried using the functions available such as mxCreateCharMatrixFromStrings but it doesn't give me the correct behavior.
So, I have something like this:
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...
The problem is how do I get this vector to the matlab environment?
plhs[0] = ???
My goal is to be able to run:
>> [strings] = MyFunc(...)
>> strings(1) = 'string 1'
© Stack Overflow or respective owner