Skip to content

nargoutchk

Validate the number of output arguments.

msg = nargoutchk(nminarg, nmaxarg)
msg = nargoutchk(nminarg, nmaxarg, numargs, 'string')

Returns an error message string if nargout (the number of requested outputs) is outside [nminarg, nmaxarg]. Used inside function bodies to enforce constraints on how many outputs the caller requested.

function [a, b, c] = foo(...)
nargoutchk(0, 3);
end
  • nargchk — Validate the number of input arguments.
  • nargout — Number of output arguments requested by the caller.