Function Reference
— Built-in Function: nargout ()
— Built-in Function: nargout (fcn_name)

Within a function, return the number of values the caller expects to receive. If called with the optional argument fcn_name, return the maximum number of values the named function can produce, or -1 if the function can produce a variable number of values.

For example,

          f ()

will cause nargout to return 0 inside the function f and

          [s, t] = f ()

will cause nargout to return 2 inside the function f.

At the top level, nargout is undefined.