title: Output a matrix with c++ and mex
body: <p>I have a problem with my c++ code. I want to return a matrix of k-dimensions from my cpp program to Matlab. </p>
  
  <p>The matrix I want to pass is stored in <code>all_data</code>, and is a matrix of size <code>(npoints+1) x ndims</code>. </p>
  
  <p>I have been looking how to do that, and I have come up with:</p>
  
  <pre><code>    //send back points
      vector&lt; vector &lt;double&gt; &gt; indexes = mxGetPr(plhs[0]);
      for (int i=0; i &lt; (npoints1+1); i++)
              for (int j=0; j &lt; ndims1; j++)
                  indexes[ i ][ j ] = all_data[ i ][ j ];
  </code></pre>
  
  <p>But it does not work, as <code>all_data</code> is a <code>vector&lt;vector&lt;double&gt;&gt;</code> variable, and matlab says:</p>
  
  <pre><code>error: conversion from 'double*' to non-scalar type 
  'std::vector&lt;std::vector&lt;double, std::allocator&lt;double&gt; &gt;, 
  std::allocator&lt;std::vector&lt;double, 
  std::allocator&lt;double&gt; &gt; &gt; &gt;' requested
  </code></pre>
  
  <p>Can someone help me out? Thanks a lot!</p>