Line | |
---|
1 | function args = argfilter(args,keep)
|
---|
2 | %ARGFILTER Remove unwanted arguments.
|
---|
3 | % ARGFILTER(ARGS,KEEP), where ARGS = {'arg1',value1,'arg2',value2,...},
|
---|
4 | % returns a new argument list where only the arguments named in KEEP are
|
---|
5 | % retained. KEEP is a character array or cell array of strings.
|
---|
6 |
|
---|
7 | % Written by Tom Minka
|
---|
8 |
|
---|
9 | if ischar(keep)
|
---|
10 | keep = cellstr(keep);
|
---|
11 | end
|
---|
12 | i = 1;
|
---|
13 | while i < length(args)
|
---|
14 | if ~ismember(args{i},keep)
|
---|
15 | args = args(setdiff_sorted(1:length(args),[i i+1]));
|
---|
16 | else
|
---|
17 | i = i + 2;
|
---|
18 | end
|
---|
19 | end
|
---|
Note: See
TracBrowser
for help on using the repository browser.