Thu 03 Jul 2014 12:29:42 PM UTC, original submission:
parameter parsing depends on the order of the arguments. Thefollowing code snippet illustrates this:
varargin = {'pval0', 0, 'pval1', 1, 'pval2', 2};
varargin1 = {'pval0', 0, 'pval2', 2, 'pval1', 1};
p = inputParser;
p.CaseSensitive = true;
p.KeepUnmatched = true;
p = p.addParamValue('pval0', 0, @isnumeric);
p = p.addParamValue('pval2', 0, @isnumeric);
res = p.parse(varargin{:})
res = p.parse(varargin1{:})
In the first case, only 'pval0' will appear in the 'Results' field of 'res'. However, if the order in which the arguments are passed is swapped, then both 'pval0' and 'pval1' are stored in 'Results'. The latter is the behavior I'd expect.
In Matlab the last two lines in the snippet above yield the same results.
|