|
I'd like to get some input on 'varargin', which I've come across
recently and have been using to add utility to various functions
depending on the number of things I choose to specify. For instance,
let's say I have a function:
function foo(varargin)
NArg = size(varargin,2);
if NArg == 1
x = varargin{1};
elseif NArg == 2
y = varargin{1};
z = varargin{2};
else
do something fancy;
end
perform some action using either x or y,z;
end
I'm sort of "overloading" that first input by letting it either be
some 'x' or some 'y'. Does anyone have any opinion on whether or not
this is a reasonable practice? Are there any potential pitfalls (aside
from poor documentation and misuse)? Input appreciated ....
|