Scrapbook of useful code snippets I found while working on projects.
Friday, July 17, 2015
Default function parameter setting in Matlab
if ~exist('param', 'var'),
param = defaultParam;
end
Note that 'param' in the first line is in single quotes. It's a string, not the parameter itself.
This allows for reordering of parameters unlike the case of checking nargin.
No comments:
Post a Comment