| MATLAB Application Program Interface | Search  Help Desk |
| mexSetTrapFlag | Examples See Also |
Control response of mexCallMATLAB to errors
C Syntax
#include "mex.h" void mexSetTrapFlag(int trap_flag);
Arguments
trap_flag0 |
On error, control returns to the MATLAB prompt. |
1 |
On error, control returns to your MEX-file. |
Description
CallmexSetTrapFlag to control MATLAB's response to errors in mexCallMATLAB.
If you do not call mexSetTrapFlag, then whenever MATLAB detects an error in a call to mexCallMATLAB, MATLAB automatically terminates the MEX-file and returns control to the MATLAB prompt. Calling mexSetTrapFlag with trap_flag set to 0 is equivalent to not calling mexSetTrapFlag at all.
If you call mexSetTrapFlag and set the trap_flag to 1, then whenever MATLAB detects an error in a call to mexCallMATLAB, MATLAB does not automatically terminate the MEX-file. Rather, MATLAB returns control to the line in the MEX-file immediately following the call to mexCallMATLAB. The MEX-file is then responsible for taking an appropriate response to the error.
Example
Seemexsettrapflag.c in the mex subdirectory of the examples directory.
See Also
mexAtExit, mexErrMsgTxt