| MATLAB Function Reference | Search  Help Desk |
| nargchk | Examples See Also |
Check number of input arguments
Syntax
msg=nargchk(low,high,number)
Description
Thenargchk function often is used inside an M-file to check that the correct number of arguments have been passed.
msg = nargchk(low,high,number)
returns an error message if number is less than low or greater than high. If number is between low and high (inclusive), nargchk returns an empty matrix.
Arguments
low, high
The minimum and maximum number of input arguments that should be passed.
number
The number of arguments actually passed, as determined by the nargin function.
Examples
Given the functionfoo:
function f = foo(x,y,z) error(nargchk(2,3,nargin))Then typing
foo(1) produces:
Not enough input arguments.
See Also
nargin, nargout