mexFunction (Fortran)
Entry point to Fortran MEX function
Fortran Syntax
#include "fintrf.h" subroutine mexFunction(nlhs, plhs, nrhs, prhs) integer nlhs, nrhs mwPointer plhs(*), prhs(*)
Arguments
nlhsNumber of expected output
mxArraysplhsArray of pointers to the expected output
mxArraysnrhsNumber of input
mxArraysprhsArray of pointers to the input
mxArrays. Do not modify anyprhsvalues in your MEX file. Changing the data in these read-onlymxArrays can produce undesired side effects.
Description
mexFunction is not a routine you call. Rather,
mexFunction is the name of the gateway subroutine in Fortran which
every MEX function requires. For more information, see Components of Fortran MEX File.
When you invoke a MEX function, MATLAB® finds and loads the corresponding MEX function of the same name. MATLAB then searches for a symbol named mexFunction within the MEX
function. If it finds one, it calls the MEX function using the address of the
mexFunction symbol. MATLAB displays an error message if it cannot find a routine named
mexFunction inside the MEX function.
When you invoke a MEX function, MATLAB automatically seeds nlhs, plhs,
nrhs, and prhs with the calling arguments. In the
syntax of the MATLAB language, functions have the general form:
[a,b,c,...] = fun(d,e,f,...)
where the ... denotes more items of the same format. The
a,b,c... are left-side output arguments, and the
d,e,f... are right-side input arguments. The arguments
nlhs and nrhs contain the number of left side and
right side arguments, respectively. prhs is an array of
mxArray pointers whose length is nrhs.
plhs is an array whose length is nlhs, where your
function must set pointers for the output mxArrays.
Note
It is possible to return an output value even if nlhs = 0, which
corresponds to returning the result in the ans variable.
Examples
To open an example, type:
edit([fullfile(matlabroot,"extern","examples","mex","filename")]);
where filename is:
Version History
Introduced before R2006a