| MATLAB® | ![]() |
#include "mex.h" int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[], const char *name);
integer*4 mexCallMATLAB(nlhs, plhs, nrhs, prhs, name) integer*4 nlhs, nrhs mwPointer plhs(*), prhs(*) character*(*) name
Number of desired output arguments. This value must be less than or equal to 50.
Array of pointers to mxArrays. The called command puts pointers to the resultant mxArrays into plhs and allocates dynamic memory to store the resultant mxArrays. By default, MATLAB automatically deallocates this dynamic memory when you clear the MEX-file. However, if heap space is at a premium, you may want to call mxDestroyArray as soon as you are finished with the mxArrays that plhs points to.
Number of input arguments. This value must be less than or equal to 50.
Array of pointers to input arguments.
Character string containing the name of the MATLAB built-in, operator, M-file, or MEX-file that you are calling. If name is an operator, just place the operator inside a pair of single quotes, for example, '+'.
0 if successful, and a nonzero value if unsuccessful.
Call mexCallMATLAB to invoke internal MATLAB numeric functions, MATLAB operators, M-files, or other MEX-files. See mexFunction for a complete description of the arguments.
By default, if name detects an error, MATLAB terminates the MEX-file and returns control to the MATLAB prompt. If you want a different error behavior, turn on the trap flag by calling mexSetTrapFlag.
It is possible to generate an object of type mxUNKNOWN_CLASS using mexCallMATLAB. For example, if you create an M-file that returns two variables but assigns only one of them a value:
function [a,b]=foo(c) a=2*c;
you get this warning message in MATLAB:
Warning: One or more output arguments not assigned during call to 'foo'.
MATLAB assigns output b to an empty matrix. If you then call foo using mexCallMATLAB, the unassigned output variable is given type mxUNKNOWN_CLASS.
See mexcallmatlab.c in the mex subdirectory of the examples directory.
Additional examples:
sincall.c in the refbook subdirectory of the examples directory
mexevalstring.c and mexsettrapflag.c in the mex subdirectory of the examples directory
mxcreatecellmatrix.c and mxisclass.c in the mx subdirectory of the examples directory
![]() | mexAtExit (C and Fortran) | mexErrMsgIdAndTxt (C and Fortran) | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |