Section: Functions and Scripts
nargout
is defined inside of all
functions. It indicates how many return values were requested from
the function when it was called. FreeMat allows for
fewer return values to be requested from a function than were declared,
and nargout
can be used to determine exactly what subset of
the functions outputs are required. There is no syntax for
the use of nargout
- it is automatically defined inside
the function body.
nargout
each time it is called.
nargouttest.m function [a1,a2,a3,a4,a5] = nargouttest printf('nargout = %d\n',nargout); a1 = 1; a2 = 2; a3 = 3; a4 = 4; a5 = 5;
--> a1 = nargouttest nargout = 1 a1 = 1 --> [a1,a2] = nargouttest nargout = 2 a1 = 1 a2 = 2 --> [a1,a2,a3] = nargouttest nargout = 3 a1 = 1 a2 = 2 a3 = 3 --> [a1,a2,a3,a4,a5] = nargouttest nargout = 5 a1 = 1 a2 = 2 a3 = 3 a4 = 4 a5 = 5