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 myfun( 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 ); mxSetPr( rhs[1], kernel ); mxSetM ( rhs[1], kernelnRows ); mxSetN ( rhs[1], kernelnCols ); mexCallMATLAB(1, lhs, 3, rhs, "conv2"); Aout = mxGetPr( lhs[0] ); }
Best Answer