Code covered by the BSD License  

Highlights from
Check the number of arguments to a function

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.31 KB File ID: #27061

Check the number of arguments to a function

by Richie Cotton

 

23 Mar 2010

Prettify checking the number of arguments to a function.

| Watch this File

File Information
Description

nargchk is used almost exclusively in one way:

error(nargchk(minargs, maxargs, nargin, 'struct'));

The third and fourth arguments are always the same, and you always wrap it in an error call.

This stupidly simple function saves you typing, and prettifies your code by wrapping the above line into something more readable, namely

CheckNumberArgs(minargs, maxargs);

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
inputs Richie Cotton 23 Mar 2010 12:21:19
utility Richie Cotton 23 Mar 2010 12:21:19

Contact us at files@mathworks.com