Consider the following function prototype
function output1 = func_name (input1)
If the function must be called with one input (there is no default) then we have a variety of input validation styles. I have seen
if (nargin == 0) print_usage (); endif
if (nargin < 1) print_usage (); endif
if (nargin != 1) print_usage (); endif
I’d like to consolidate the core m-files to use a single style. Does anybody have a preference for one of the three styles and any reasoning behind it?
I prefer the middle one because it references the number of arguments that are required (1) and because it would be consistent with functions which require a minimum number of arguments where that number is greater than 1. For example, `
if (nargin < 3) print_usage (); endif
for a function which requires three (3) arguments.