function varargout = addmult_catch(varargin)
% ADDMULT_CATCH Solution using TRY-CATCH syntax.

if nargin < 2
  error('Too few input arguments.');
end

s = 0; p = 1;

try
  for ix = 1:nargin      % Loop through inputs
    val = varargin{ix};  % Extract using curly braces
    s = s + val;         % Sum increases by value
    p = p .* val;        % Product is multiplied
  end
catch                    % If an error occurs...
  warning('addmult_catch:badInput',...
    'Inputs do not match in size!');
  s = [];
  p = [];
end

% Rest of code, same as before.
% Concatenate outputs if needed.

if nargout < 2         % nargout can be zero!
  warning('addmult_catch:twoOut',...
    'This function prefers two outputs.'); 
  varargout{1} = [s p];  % Concatenate outputs
else                   
  varargout{1} = s;
  varargout{2} = p;    % Separate if two outputs
end