23.07.2012 Views

MATLAB C++ Math Library Reference

MATLAB C++ Math Library Reference

MATLAB C++ Math Library Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The mwVarargin and mwVarargout Classes<br />

15<br />

<strong>MATLAB</strong> supports functions that accept a variable number of input arguments<br />

and return a variable number of return values. The <strong>C++</strong> <strong>Math</strong> <strong>Library</strong> defines<br />

two classes to handle these functions.<br />

• The mwVarargin class<br />

• The mwVarargout class<br />

The mwVarargin Class<br />

<strong>MATLAB</strong> <strong>C++</strong> <strong>Math</strong> <strong>Library</strong> functions that take a variable number of input<br />

arguments have one mwVarargin argument followed by 31 additional mwArray<br />

arguments.<br />

• If you pass 32 or fewer arguments, you can ignore the mwVarargin parameter<br />

and simply pass a series of mwArrays as with any other function.<br />

• Ifyouneedtopassmorethan32inputs,youmustconstructanmwVarargin<br />

object and pass it as the mwVarargin parameter.<br />

Constructors<br />

The mwVarargin constructor has the standard varargin parameter list: one<br />

mwVarargin argument followed by 31 additional mwArray arguments. The<br />

mwVarargin constructors can be nested enabling you to pass an unlimited<br />

number of inputs.<br />

The inputs used to construct the mwVarargin argument appear first on the<br />

argument list for the function, followed by the remaining 31 inputs. It is not<br />

necessary to fill out the mwVarargin constructor parameter list. The arguments<br />

can be distributed between the mwVarargin constructor and the remaining 31<br />

arguments.<br />

For example, the library function horzcat() is a varargin function that<br />

demonstrates the standard varargin parameter list. Its function prototype is<br />

mwArray horzcat(const mwVarargin &in1=mwArray::DIN,<br />

const mwArray &in2=mwArray::DIN,<br />

.<br />

.<br />

.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!