function tot = v_error_check(varargin)
% Sum the three input arguments. If there is only two inputs
% let the third argument be the sum of the two inputs.
msg = nargchk(2,3,nargin);
if msg
	error(msg)
end

if nargin == 3
	z = varargin{3};
end

x = varargin{1};
y = varargin{2};
if ~exist('z', 'var') %Could also use if nargin == 2
   z = x + y;
end

tot = x + y + z;
