function tot = v_error_check(varargin)
% Sum the three input arguments. If there are only two inputs,
% let the third argument be the sum of the two inputs.
msg = nargchk(2,3,nargin);
if ~isempty(msg)
  error(msg)
end
x = varargin{1};
y = varargin{2};
if nargin < 3
  z=x+y;
else
  z = varargin{3};
end
tot = x + y + z;
