https://www.mathworks.com/help/releases/R2018b/matlab/ref/nargout.html
nargout
Number of function output arguments
Syntax
nargout
-
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.nargout([
fun](https://www.mathworks.com/help/releases/R2018b/matlab/ref/nargout.html#bsyib3_-1-fun))
returns the number of outputs that appear in thefun
function definition. If the function includesvarargout
in its definition, thennargout
returns the negative of the number of outputs. For example, if functionmyFun
declares outputsy
,z
, andvarargout
, thennargout('myFun')
returns-3
.