| MATLAB Application Program Interface | Search  Help Desk |
| mexErrMsgTxt | Examples See Also |
Issue error message and return to the MATLAB prompt
#include "mex.h" void mexErrMsgTxt(const char *error_msg);error_msg
mexErrMsgTxt to write an error message to the MATLAB window. After the error message prints, MATLAB terminates the MEX-file and returns control to the MATLAB prompt.
Calling mexErrMsgTxt does not clear the MEX-file from memory. Consequently, mexErrMsgTxt does not invoke the exit function.
If your application called mxCalloc or one of the mxCreate routines to allocate memory, mexErrMsgTxt automatically frees the allocated memory.
Determine the number of input arguments passed to the MEX-file. If that number is not 2, display an error message and return to the MATLAB prompt
void
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray
*prhs[])
{
if (nrhs != 2)
mexErrMsgTxt("You must pass 2 rhs args.");
else {
...
}
For an additional example, see mexerrmsgtxt.c in the mex subdirectory of the examples directory.
mexWarnMsgTxt