| CS 1371 Dept. Presents: |
| NARGIN | |
|---|---|
| Definition | Number of function input arguments. Inside the body of a user-defined
function, NARGIN returns the number of input arguments that were used to call
the function. |
| Example |
function acct =
BankAccount(data)
if nargin == 0 acct.balance = 0;
acct = class(acct,'BankAccount');
elseif
isa(data,
'BankAccount')
acct = data;
else
acct.balance = data;
acct = class(acct,'BankAccount');
end
In this example, if the number of input arguments was 0, then it creates a new field called balance in the class BankAccount |