function rval = errorreturn(a, b)
% rval Demonstrates use or return statement to exit function.
%
% Returns the sum of its two inargs, providing that the first
% is strictly positive, otherwise it prints an error message and 
% exits using the return statement.

   % Assign a "default" value to the output argument to ensure that it 
   % IS defined before the function returns.  
   rval = NaN;

   if a <= 0 
      % Print the error message and return.
      fprintf('errorreturn: First argument must be > 0\n');
      return;
   end

   % Return the normal value.
   rval = a + b;
end
