Main Content

mexCallMATLABWithTrap (C and Fortran)

Call MATLAB function, user-defined function, or MEX file and capture error information

C Syntax

#include "mex.h"
mxArray *mexCallMATLABWithTrap(int nlhs, mxArray *plhs[], int nrhs,
   mxArray *prhs[], const char *functionName);

Fortran Syntax

#include "fintrf.h"
mwPointer mexCallMATLABWithTrap(nlhs, plhs, nrhs, prhs, functionName)
integer*4 nlhs, nrhs
mwPointer plhs(*), prhs(*)
character*(*) functionName

Description

The mexCallMATLABWithTrap function performs the same function as mexCallMATLAB. However, if MATLAB® detects an error when executing functionName, MATLAB returns control to the line in the MEX file immediately following the call to mexCallMATLABWithTrap.

Input Arguments

expand all

Number of expected output mxArrays, specified as an integer less than or equal to 50.

Array of pointers to the mxArray output arguments.

Caution

The plhs argument for mexCallMATLAB is not the same as the plhs for mexFunction. Do not destroy an mxArray returned in plhs for mexFunction.

Number of input mxArrays, specified as an integer less than or equal to 50.

Array of pointers to the mxArray input arguments.

Name of the MATLAB built-in function, operator, user-defined function, or MEX function to call specified as const char*.

If functionName is an operator, place the operator inside a pair of single quotes, for example, '+'.

Output Arguments

expand all

NULL if no error occurred. Otherwise, returns a pointer specified as mxArray* in C or mwPointer in Fortran of class MException. For information about MException, see Respond to an Exception.

Introduced in R2008b