title: How to create a string array in MATLAB?
body: <p>I would like to pass a vector of strings from C++ to MATLAB. I have tried using the functions available such as <code>mxCreateCharMatrixFromStrings</code>, but it doesn't give me the correct behavior. </p>
  
  <p>So, I have something like this:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void mexFunction(
      int nlhs, mxArray *plhs[],
      int nrhs, const mxArray *prhs[])
  {
     vector&lt;string&gt; stringVector;
     stringVector.push_back("string 1");
     stringVector.push_back("string 2");
     //etc...
  </code></pre>
  
  <p>The problem is how do I get this vector to the matlab environment?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>   plhs[0] = ???
  </code></pre>
  
  <p>My goal is to be able to run:</p>
  
  <pre class="lang-matlab prettyprint-override"><code>&gt;&gt; [strings] = MyFunc(...)
  &gt;&gt; strings(1) = 'string 1'
  </code></pre>