1function options=ParseOptPara(options,Names,Types,Values,OptParas)
3for i=1:2:size(OptParas,2)
5 if (i+1 <= size(OptParas,2))
7 arg=strmatch(prop,Names,
'exact');
8 if (isempty(arg)) % checks whether Invalid Property
9 warning(
'MATLAB:ParseOptPara:InvalidPropName',...
10 'Property name ''%s'' not recognized and ignored',prop);
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:ParseOptPara:InvalidPropValue',...
17 'Property value ''%s'' of ''%s'' not allowed and ignored',value,prop);
21 elseif (strmatch(
'numeric',Types(arg,:),
'exact')) % property values are numeric
24 else % incorrect
property value type
26 warning(
'MATLAB:ParseOptPara:InvalidPropType',...
27 'Property value ''%s'' of ''%s'' has an incorrect type and is ignored',value,prop);
31 warning(
'MATLAB:ParseOptPara:InvalidPropType',...
32 'Property value %d of ''%s'' has an incorrect type and is ignored',value,prop);
37 else % odd number of optional parameters
38 warning(
'MATLAB:ParseOptPara:OddNumbOptParas',...
39 'An odd number of optional parameters detected, last parameter ''%s'' ignored',prop);