This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mexErrMsgTxt (C and Fortran)

Display error message and return to MATLAB prompt


mexErrMsgTxt is not recommended. Use mexErrMsgIdAndTxt instead.

C Syntax

#include "mex.h"
void mexErrMsgTxt(const char *errormsg);

Fortran Syntax

subroutine mexErrMsgTxt(errormsg)
character*(*) errormsg



String containing the error message to display


mexErrMsgTxt writes 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. So, mexErrMsgTxt does not invoke the function registered through mexAtExit.

If your application called mxCalloc or one of the mxCreate* routines to allocate memory, mexErrMsgTxt automatically frees the allocated memory.


If you get warnings when using mexErrMsgTxt, you might have a memory management compatibility problem. For more information, see Memory Management Issues.


In addition to the errormsg, the mexerrmsgtxt function determines where the error occurred, and displays the following information. If an error labeled Print my error message occurs in the function foo, mexerrmsgtxt displays:

Error using foo
Print my error message
Was this topic helpful?