Constructing an mwVarargin Object
MATLAB C++ Math Library functions that take a variable number of input arguments have one mwVarargin argument followed by 31 additional mwArray arguments.
The mwVarargin constructor has the standard varargin parameter list: one mwVarargin argument followed by 31 additional mwArray arguments. The mwVarargin constructors can be nested enabling you to pass an unlimited number of inputs.
The inputs used to construct the mwVarargin argument appear first on the argument list for the function, followed by the remaining 31 inputs. It is not necessary to fill out the mwVarargin constructor parameter list. The arguments can be distributed between the mwVarargin constructor and the remaining 31 arguments.
For example, the library function horzcat() is a varargin function that demonstrates the standard varargin parameter list. Its function prototype is
mwArray horzcat(const mwVarargin &in1=mwArray::DIN,
const mwArray &in2=mwArray::DIN,
.
.
.
const mwArray &in32=mwArray::DIN);
To pass 90 inputs to the horzcat function, make this call:
horzcat(mwVarargin(mwVarargin(p1,p2,...,p32), p33, ..., p63),
p64, ..., p90);
The first 32 arguments are passed to an mwVarargin constructor that is nested as the first argument to another mwVarargin constructor. The next 31 arguments (p33 through p63) are passed as mwArray arguments to the mwVarargin object that is the first argument to horzcat(). The remaining arguments (p64 through p90) are passed as additional mwArray arguments to the function.
Note that the ... represent omitted aguments in the series and are not part of the actual function prototype or function call.
Note If a function takes any required output arguments, an mwVarargout argument, or any required or optional input arguments, these arguments precede the first mwVarargin argument in the list of arguments.
[ Previous | Help Desk | Next ]