LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ParseOptPara.m
1function options=ParseOptPara(options,Names,Types,Values,OptParas)
2for i=1:2:size(OptParas,2)
3 prop=OptParas{i};
4 if (i+1 <= size(OptParas,2))
5 value=OptParas{i+1};
6 arg=strmatch(prop,Names,'exact');
7 if (isempty(arg)) % checks whether Invalid Property
8 warning('MATLAB:ParseOptPara:InvalidPropName',...
9 'Property name ''%s'' not recognized and ignored',prop);
10 else
11 if (eval(['is' Types(arg,:) '(value)'])) % checks whether property value is of correct type
12 if (strmatch('char',Types(arg,:),'exact')) % property values are strings
13 %if (isempty(strmatch(value,eval([prop 'Value']),'exact')))
14 if (isempty(strmatch(value,Values{arg},'exact')))
15 warning('MATLAB:ParseOptPara:InvalidPropValue',...
16 'Property value ''%s'' of ''%s'' not allowed and ignored',value,prop);
17 else
18 options.(prop)=value;
19 end
20 elseif (strmatch('numeric',Types(arg,:),'exact')) % property values are numeric
21 options.(prop)=value;
22 end
23 else % incorrect property value type
24 if (ischar(value))
25 warning('MATLAB:ParseOptPara:InvalidPropType',...
26 'Property value ''%s'' of ''%s'' has an incorrect type and is ignored',value,prop);
27
28 end
29 if (isnumeric(value))
30 warning('MATLAB:ParseOptPara:InvalidPropType',...
31 'Property value %d of ''%s'' has an incorrect type and is ignored',value,prop);
32
33 end
34 end
35 end
36 else % odd number of optional parameters
37 warning('MATLAB:ParseOptPara:OddNumbOptParas',...
38 'An odd number of optional parameters detected, last parameter ''%s'' ignored',prop);
39 end
40end