MATLAB Compiler | ![]() ![]() |
C Interface Functions
The C interface functions process any input arguments and pass them to the implementation version of the function, M
f
.
mlxF Interface Function
The Compiler always generates the mlx
F
interface function, which is used by feval
. At times, the Compiler needs to use feval
to perform argument matching even if the user does not specifically call feval
. For example,
x = cell(1,5); y = {1 2 3 4 5}; [x{:}] = deal(y{:});
would use the feval
interface. The following C code is the corresponding feval
interface (mlxGasket
) from the Sierpinski Gasket example. This function calls the C Mgasket
function.
/* * The function "mlxGasket" contains the feval interface * for the "gasket" M-function from file * "<matlab>\extern\examples\compiler\gasket.m" (lines 1-23). * The feval function calls the implementation version of * gasket through this function. This function processes * any input arguments and passes them to the * implementation version of the function, appearing above. */ void mlxGasket(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) { mxArray * mprhs[1]; mxArray * mplhs[1]; int i;
![]()
mlfF Interface Function
The Compiler always generates the mlf
F
interface function, which contains the "normal" C interface to the function. This code is the corresponding C interface function (mlfGasket
) from the Sierpinski Gasket example. This function calls the C mgasket
function.
mlfNF Interface Function
The Compiler produces this interface function only when the M-function uses the variable nargout
.The nargout
interface allows you to specify the number of requested outputs via the int nargout
argument, as opposed to the normal interface that dynamically calculates the number of outputs based on the number of non-null inputs it receives.
This is the corresponding mlfN
F
interface function (mlfNFoo
) for the foo.m example described earlier in this chapter. This function calls the Mfoo
function that appears in foo.c
.
/* * The function "mlfNFoo" contains the nargout interface * for the "foo" M-function from file * "<matlab>\extern\examples\compiler\foo.m" (lines 1-8). * This interface is only produced if the M-function uses * the special variable "nargout". The nargout interface * allows the number of requested outputs to be specified * via the nargout argument, as opposed to the normal * interface which dynamically calculates the number of * outputs based on the number of non-NULL inputs it * receives. This function processes any input arguments * and passes them to the implementation version of the * function, appearing above. */
![]()
mlfVF Interface Function
The Compiler produces this interface function only when the M-function uses the variable nargout
and has at least one output. This void
interface function specifies zero output arguments to the implementation version of the function, and in the event that the implementation version still returns an output (which, in MATLAB, would be assigned to the ans
variable), it deallocates the output.
This is the corresponding mlfV
F
interface function (mlfVFoo
) for the foo.m example described at the beginning of this section. This function calls the C Mfoo
implementation function that appears in foo.c
.
/* * The function "mlfVFoo" contains the void interface for * the "foo" M-function from file * "<matlab>\extern\examples\compiler\foo.m" (lines 1-8). The * void interface is only produced if the M-function uses * the special variable "nargout", and has at least one * output. The void interface function specifies zero * output arguments to the implementation version of the * function, and in the event that the implementation * version still returns an output (which, in MATLAB, would * be assigned to the "ans" variable), it deallocates the * output. This function processes any input arguments and * passes them to the implementation version of the * function, appearing above. */
![]()
![]() | Internal Interface Functions | C++ Interface Functions | ![]() |