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