title: Assign float * or int * to mxArray
body: <p>I got a typical cpp function in matlab using mex</p>
  
  <pre><code>#include "mex.h"
  
  void func (int * rowvec, int * colvec, float * valvec, int * nnz){/*fill arguments*/}
  
  
  
  void mexFunction(int nlhs, mxArray *plhs[],
                   int nrhs, const mxArray *prhs[])
  </code></pre>
  
  <p>where I check that in I have enough output variables available</p>
  
  <pre><code>if(nlhs != 4) {
    mexErrMsgIdAndTxt("MyToolbox:arrayProduct:nlhs",
                    "Four outputs required.");
  }
  </code></pre>
  
  <p>Furthermore, in this function I declare four variables:</p>
  
  <pre><code>int *rowvec;        /* 1st output array */
  int *colvec;        /* 2nd output array */
  float *valvec;      /* 3rd output array */
  int *nnz;           /* 4th output scalar */
  </code></pre>
  
  <p>They will be defined/filled in a function:</p>
  
  <pre><code>func(rowvec, colvec, valvec, nnz) //arguments get filled with values
  </code></pre>
  
  <p>Now I want to do something like that:</p>
  
  <pre><code>plhs[0] = rowvec;
  plhs[1] = colvec;
  plhs[2] = valvec;
  plhs[3] = nnz;
  </code></pre>
  
  <p>It unfortunately throws four understandable errors, because those are two different data types. The errors are like this:</p>
  
  <pre><code>cannot convert ‘int*’ to ‘mxArray* {aka mxArray_tag*}’ in assignment plhs[0] = rowvec;
  </code></pre>
  
  <p>How can I fix this?</p>