Validate number of output arguments
nargoutchk( validates the number of output arguments specified in the current function call. minArgs,maxArgs)nargoutchk throws an error if the number of outputs is less than minArgs or greater than maxArgs. If the number of outputs is between minArgs and maxArgs (inclusive), then nargoutchk does nothing.
To verify that you have a minimum number of arguments, but no maximum number, set maxArgs to inf. For example: nargoutchk(5,inf) throws an error when there are fewer than five outputs.
To verify that you have an exact number of arguments, specify the same value for minArgs and maxArgs. For example: nargoutchk(3,3) throws an error when you do not have exactly three outputs.
If minArgs is 0 and maxArgs is nargout, then you do not need to use nargoutchk.