# nargin

Number of input arguments

### nargin

• It returns the number of input arguments required by a user-defined funciton.
• It has to be called within a user-defined function.

Example 1: User-defined function f is given below, which requires 3 input arguments.

function [a,b]=f(c,d,e)
disp('Number of input arguments required:')
nargin
a=c;
b=d;


Running f(1,2,3); gives the following output.

Number of input arguments required:

ans =
3.000


### nargin(name)

• It returns the number of input arguments required by a user-defined funciton named fname.
• The m file defining the function should be in the working folder.

Example 2: f is the function defined in Example 1 above.

nargin('f')

ans =
3.000