nargout
Number of output arguments requested by the caller.
Syntax
Section titled “Syntax”n = nargoutDescription
Section titled “Description”Inside a function body, returns how many output values the caller’s destructuring requested. Common for skipping expensive computations whose results aren’t going to be used:
function [m, idx] = costly(A) m = ... % always compute if nargout >= 2 % only compute idx if needed idx = ... endendExample
Section titled “Example”if nargout > 1; computeOptional(); endSee also
Section titled “See also”nargin— Number of input arguments passed to the current function.nargoutchk— Validate the number of output arguments.