function [varargout] = vararg_example(varargin)
%
% This function accepts an arbitrary number of scalar input arguments,
% multiplies them by two, and returns those (as many as are requested).
%

% unpack input arguments into a vector
for i=1:length(varargin)
  x(i) = varargin{i};
end

for i=1:nargout
  varargout{i} = 2*x(i);
end