title: convert from float* to vector<float >
body: <p>I have a function 
  <code>float * pointwise_search(vector&lt;float &gt; &amp;P,vector&lt;float &gt; &amp;Q,float* n, int len )</code>.</p>
  
  <p>I want matlab call it so I need to write a mexFunction.</p>
  
  <pre><code>void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 
  { 
      if (nrhs != 4)
      {
          mexErrMsgTxt("Input is wrong!");
      }
  
      float *n = (float*) mxGetData(prhs[2]);
      int len = (int) mxGetScalar(prhs[3]);
      vector&lt;float &gt; Numbers= (vector&lt;float &gt;)mxGetPr(prhs[0]);
      vector&lt;float &gt; Q= (vector&lt;float &gt;)mxGetPr(prhs[1]);
  
      plhs[1] = pointwise_search(Numbers,Q,n,len );
  
    }
  </code></pre>
  
  <p>But I found that <code>vector&lt;float &gt; Numbers= (vector&lt;float &gt;)mxGetPr(prhs[0]);
          vector&lt;float &gt; Q= (vector&lt;float &gt;)mxGetPr(prhs[1]);</code> are wrong. </p>
  
  <p>So I have to change <code>float * pointwise_search(vector&lt;float &gt; &amp;P,vector&lt;float &gt; &amp;Q,float* n, int len )</code> to <code>float * pointwise_search(float *P,float *Q,float* n, int len )</code>.</p>
  
  <p>According to the answers, I rewrite as the following </p>
  
  <pre><code> float * pointwise_search(float p,float *q,int num_thres, float n, int len ) 
  {    vector&lt;float&gt; P{p, p + num_thres}; 
       vector&lt;float&gt; Q{q, q + num_thres}; 
       int size_of_threshold = P.size();
  ...
  } 
  </code></pre>
  
  <p>But there occur errors.</p>
  
  <p><code>pointwise_search.cpp(12) : error C2601: 'P' : local function definitions are illegal 
          pointwise_search.cpp(11): this line contains a '{' which has not yet been matched</code></p>
  
  <p>As the comment,I should change <code>vector&lt;float&gt; P{p, p + num_thres};</code> to <code>vector&lt;float&gt; P(p, p + num_thres);</code>. :）</p>