Number of function input arguments
nargin returns the number of function input arguments given in the call to the currently executing function. Use this syntax in the body of a function only. When using an arguments validation block, the value returned by nargin within a function is the number of positional arguments provided when the function is called. For more information, see nargin in Argument Validation.
nargin( returns the number of input arguments that appear in the fun)fun function definition. If the function includes varargin in its definition, then nargin returns the negative of the number of inputs. For example, if function myFun declares inputs a, b, and varargin, then nargin('myFun') returns -3.
If the input argument refers to a function that uses an arguments validation block, then the returned value is the number of declared positional arguments in the function definition as a non-negative value.