nargin, nargout
There are two special identifiers, nargin and nargout, that indicate the number of parameters passed into and the number of parameters returned from the function respectively.
function [x,y] = goo(a,b,c)
print(nargin)
print(nargout)
x=a+b
y=b+c
end
function [y1, y2, y3] = foo(x1, x2)
y1=x1;
y2=x2;
y3=x1+x2;
end
nargin('foo')
nargout('foo')
This returns 2 and 3.
function [y1, y2, varargout] = goo(x1, varargin)
y1=x1;
y2=x2;
y3=x1+x2;
end
nargin('goo')
nargout('goo')
This returns -2 and -3.