28.12.2012 Views

Figure Properties - SERC

Figure Properties - SERC

Figure Properties - SERC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

nargchk<br />

2nargchk<br />

Purpose Check number of input arguments<br />

Syntax msgstring = nargchk(minargs, maxargs, numargs)<br />

msgstring = nargchk(minargs, maxargs, numargs, 'string')<br />

msgstruct = nargchk(minargs, maxargs, numargs, 'struct')<br />

Description Use nargchk inside an M-file function to check that the desired number of input<br />

arguments is specified in the call to that function.<br />

2-1512<br />

msgstring = nargchk(minargs, maxargs, numargs) returns an error<br />

message string msgstring if the number of inputs specified in the call numargs<br />

is less than minargs or greater than maxargs. If numargs is between minargs<br />

and maxargs (inclusive), nargchk returns an empty matrix.<br />

It is common to use the nargin function to determine the number of input<br />

arguments specified in the call.<br />

msgstring = nargchk(minargs, maxargs, numargs, 'string') is<br />

essentially the same as the command shown above, as nargchk returns a string<br />

by default.<br />

msgstruct = nargchk(minargs, maxargs, numargs, 'struct') returns an<br />

error message structure msgstruct instead of a string. The fields of the return<br />

structure contain the error message string and a message identifier. If numargs<br />

is between minargs and maxargs (inclusive), nargchk returns an empty<br />

structure.<br />

When too few inputs are supplied, the message string and identifier are<br />

message: 'Not enough input arguments.'<br />

identifier: 'MATLAB:nargchk:notEnoughInputs'<br />

When too many inputs are supplied, the message string and identifier are<br />

message: 'Too many input arguments.'<br />

identifier: 'MATLAB:nargchk:tooManyInputs'<br />

Remarks nargchk is often used together with the error function. The error function<br />

accepts either type of return value from nargchk: a message string or message<br />

structure. For example, this command provides the error function with a<br />

message string and identifier regarding which error was caught:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!