User`s guide

5 Controlling Code Generation
5-18
//
// The function "gasket" contains the normal interface for
// the "gasket" M-function from file
// "<matlab>\extern\examples\compiler\gasket.m" (lines 1-23).
// This function processes any input arguments and passes
// them to the implementation version of the function,
// appearing above.
//
mwArray gasket(mwArray numPoints) {
int nargout = 1;
mwArray theImage = mwArray::UNDEFINED;
// ----------------- Call M-Function ---------------------
theImage = Mgasket(nargout, numPoints);
// ------------- Output Argument Processing --------------
return theImage;
}
NF Interface Function
The Compiler produces this interface function only when the M-function uses
the variable
nargout. The nargout interface allows the number of requested
outputs to be specified via the
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
NF interface function (NFoo) for the foo.m example
described earlier in this chapter. This function calls the
Mfoo function
appearing in
foo.cpp:
//
// The function "Nfoo" 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