MATLAB crashes when it reaches mxSetPr in a mex file
I am writing a function within in a mex file which calls a MATLAB function. Unfortunately, when it comes to mxSetPr , MATLAB crashes and does not proceed further. Could someone kindly tell me how I can fix this? void myconv2( double * Ain , double *Aout, int AnRows , int AnCols, double* kernel, int kernelnRows, int kernelnCols ) { mxArray *rhs[3], *lhs[1]; rhs[0] = mxCreateNumericMatrix( 0, 0, mxDOUBLE_CLASS, mxREAL ); rhs[1] = mxCreateNumericMatrix( 0, 0, mxDOUBLE_CLASS, mxREAL ); rhs[2] = mxCreateString ( "same" ); mxSetPr( rhs[0], Ain ); mxSetM ( rhs[0], AnRows ); mxSetN ( rhs[0], AnCols );