Main Content

Error Handling

The mexErrMsgIdAndTxt function prints error information and terminates your binary MEX file. For an example, see the following code in matlabroot/extern/examples/mx/mxcreatecellmatrixf.F.

C     Check for proper number of input and output arguments    
      if (nrhs .lt. 1) then
         call mexErrMsgIdAndTxt( 'MATLAB:mxcreatecellmatrixf:minrhs',
     +    'One input argument required.')
      end if

The mexWarnMsgIdAndTxt function prints information, but does not terminate the MEX file. For an example, see the following code in matlabroot/extern/examples/mx/mxgetepsf.F.

C     Check for equality within eps 
      do 20 j=1,elements
    	 if ((abs(first(j) - second(j))).gt.(abs(second(j)*eps))) then
	      call mexWarnMsgIdAndTxt(
     +     'MATLAB:mxgetepsf:NotEqual',
     +     'Inputs are not the same within eps.')
    	    go to 21
	     end if
   20 continue

See Also

|

Related Topics