title: Using mxGetPr vs mxGetData
body: <p>I am trying to write a simple mex function. I have an integer input which is the number of my objects.
  When I compile <code>myMEX_1.cpp</code> and call it by MATLAB with any input value, I always get:</p>
  
  <blockquote>
    <p>Number of Requested Objects := 0</p>
  </blockquote>
  
  <p>But the <code>myMEX_2.cpp</code> works fine and show the number inputted from MATLAB command window.
  Where is the my mistake in <code>myMEX_1.cpp</code>?  </p>
  
  <p><em>My enviroment: MATLAB R2013a and Microsoft SDK 7.1 compiler.</em></p>
  
  <pre><code>// myMEX_1.cpp
  #include "mex.h" 
  void mexFunction(int nlhs,       mxArray *plhs[], 
                   int nrhs, const mxArray *prhs[]) 
  {
  
      char str11[100];
      unsigned short frameCount;
      //unsigned short *frameCountPtr;
      frameCount = (*((unsigned short*)mxGetData(prhs[0])));
      sprintf(str11, "Number of Requested Objects := %d:\n", frameCount);
      mexPrintf(str11);
  }
  
  
  
  
  
  // myMEX_2.cpp
  #include "mex.h" 
  void mexFunction(int nlhs,       mxArray *plhs[], 
                   int nrhs, const mxArray *prhs[]) 
  {
     char str11[100];
     unsigned short frameCount;
     double* dblPointer; 
     dblPointer = mxGetPr(prhs[0]);
     frameCount = (unsigned short)(*dblPointer);
     sprintf(str11, "Number of Requested Objects := %d:\n", frameCount);
     mexPrintf(str11);
  }
  </code></pre>