nargout
Number of function output arguments
Syntax
Description
nargout
returns the number of function output arguments specified in the call to the currently executing function. Use this syntax in the body of a function only.
Examples
Input Arguments
Tips
When you use a function as part of an expression, such as an
if
statement, then MATLAB®calls the function with one output argument. Therefore, thenargout
function returns1
within expressions.If you check for a
nargout
value of 0 within a function and you specify the value of the output, MATLAB populatesans
. However, if you checknargout
and do not specify a value for the output, then MATLAB does not modifyans
.