MATLAB Application Program Interface Reference | Help Desk |
mexErrMsgTxt
Issue error message and return to the MATLAB prompt
#include "mex.h" void mexErrMsgTxt(const char *error_msg);error_msg
String containing the error message to be displayed.
CallmexErrMsgTxt
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; you passed %d.", nrhs); else { ... }For an additional example, see
mexErrMsgTxt.c
in the mex
subdirectory of the examples
directory.
mexWarnMsgTxt