Given a function like:
function foo(myParam)
if nargin<1
myParam = \'default value\';
end % if
end % function
I\'ve seen people use so
I would go with nargin for two reasons:
If you change the order of parameters to your function, fixing up the input checking code is going to be the least of your problems; you're going to have to go update all the call sites to your function as well.
nargin is far cheaper. exist, even if scoped to just check for variables, has to scan the whole workspace doing a bunch of string comparisons along the way. the nargin method consists of just a scalar less than operation.