Variable Arguments

Functions can be written to accept or return an indefinite (or 'variable') number of arguments. To do so, use the varargin and varargout variables.

In the most general form, a definition of a function with both variable input and output arguments would be:
varargout = function myfunc(varargin)

Note that varargout and varargin variables are cell arrays.