Having an inconsistent Performance of running a MATLAB/MEX file -
i have written mex file. file compiles no problem. reasons, baffled, mex file not work more. nothing has changed. using same mex code , same arguments executing mex file. fails. uninstalled , reinstalled matlab did not help. i tracked problem , seems when reaches mexcallmatlab , causes crash. mxarray *x_locations = ( cellcentered ) ? mxcreatedoublematrix( 1, nz-1, mxreal ) : mxcreatedoublematrix( 1, nz, mxreal ); mxarray *y_locations = ( cellcentered ) ? mxcreatedoublematrix( 1, ny-1, mxreal ) : mxcreatedoublematrix( 1, ny, mxreal ); mxarray *z_locations = ( cellcentered ) ? mxcreatedoublematrix( 1, nx-1, mxreal ) : mxcreatedoublematrix( 1, nx, mxreal ); // loop filling values x_locations, y_locations, z_locations // ... // end of loop // create meshgrid based on values stored in x_locations, y_locations, z_locations mxarray *in[3]; mxarray *out[3]; in[0] = x_locations; in[1] = y_locations; in[2] = z_locations; mexprintf("line before mexcallmatlab\n"); mexcal