n = nargin
n = nargout
nargin
and nargout
indicate how many input or output arguments, respectively, a user has supplied.
nargin
returns the number of input arguments specified for a function.
nargout
returns the number of output arguments specified for a function.
fplot
, which has an optional number of input and output arguments:
function [x0,y0] = fplot(fname,lims,npts,angl,subdiv)
%FPLOT Plot a function.
% FPLOT(fname,lims,npts,angl,subdiv)
% The first two input arguments are% required; the other three have default values.
...
% [x,y] = fplot(...) returns x and y instead
% of plotting them.
...
if nargin < 5, subdiv = 20; end
if nargin < 4, angl = 10; end
if nargin < 3, npts = 25; end
...
if nargout == 0
plot(x,y)
else
x0 = x;
y0 = y;
end
(c) Copyright 1994 by The MathWorks, Inc.