nargin
Returns the number of input arguments.
📝Syntax
R = nargin()
R = nargin(function_name)
R = nargin(function_handle)
📥Input Arguments
Parameter Description
function_name a string: function name
function_handle a function handle
📤Output Arguments
Parameter Description
R an integer value: number of input arguments
📄Description

nargin returns the number of input arguments of a function.

When called without an input argument, nargin returns the number of input arguments used to call the currently executing function.

When called with a function name or function handle, nargin returns the number of input arguments declared by that function.

If the last declared input argument is varargin, the returned value is negative. Its absolute value is the total number of declared input arguments, including varargin. For example, for a function declared as f(a, b, varargin), nargin('f') returns -3.

💡Examples
With an macro function:
nargin('getfield')
With an builtin function:
nargin('cos')
🔗See Also
nargout
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub