varargin

Specify that a function can take a variable number of arguments.

Syntax

function goo(a,varargin)
end

Inputs

varargin
Whatever can be assigned to a variable.
Type: double | char | logical | struct | cell | integer
Dimension: scalar | vector | matrix

Example

Simple varargin example.
Note: varargin must be the last variable in the argument list.
function goo(a,varargin)
  disp(a)
  disp(varargin{1}) % it should print 2 here
  end

goo(1,2,3);
1
2