Navigation

Operators and Keywords

Function List:

C++ API

: nargin ()
: nargin (fcn)

Report the number of input arguments to a function.

Called from within a function, return the number of arguments passed to the function. At the top level, return the number of command line arguments passed to Octave.

If called with the optional argument fcn—a function name or handle—return the declared number of arguments that the function can accept.

If the last argument to fcn is varargin the returned value is negative. For example, the function union for sets is declared as

function [y, ia, ib] = union (a, b, varargin)

and

nargin ("union")
⇒ -3

Programming Note: nargin does not work on compiled functions (.oct files) such as built-in or dynamically loaded functions.

See also: nargout, narginchk, varargin, inputname.

Package: octave