title: Issue about logical output from MEX function in MATLAB
body: <p>Why is the output always 1 from my MEX function although it was expected to be 0?</p>
  
  <p>I wrote the following MEX source code shown below</p>
  
  <pre><code>#include "mex.h"
  
  void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
  {
    bool *x,*y;
  
    /* Create matrix for the return argument. */
    plhs[0] = mxCreateLogicalMatrix(1,1);
  
    /* Assign pointers to each input and output. */
    x = mxGetLogicals(prhs[0]); //input
    y = mxGetLogicals(plhs[0]); //output
  
    /* Calculations. */
    if (*x == 0) *y = 1;
    else *y = 0;
  }
  </code></pre>
  
  <p>and the following appears:</p>
  
  <pre><code>y = test(5)
  
  y =
  
       1
  </code></pre>