%  Retrieve the nth output in a function return list (already exists in octave) 
function out = nthargout(n, varargin)
  if (isa (varargin{1}, "function_handle") || ischar (varargin{1}))
    ntot = max (n(:));
    func = varargin{1};
    args = varargin(2:end);
  end

  outargs = cell (1, ntot);

  [outargs{:}] = feval (func, args{:});
  if (numel (n) > 1)
    out = outargs(n);
  else
    out = outargs{n};
  end
end
