1function options=ParseOptPara(options,Names,Types,Values,OptParas)
2for i=1:2:size(OptParas,2)
4 if (i+1 <= size(OptParas,2))
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);
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);
20 elseif (strmatch(
'numeric',Types(arg,:),
'exact')) % property values are numeric
23 else % incorrect
property value type
25 warning(
'MATLAB:ParseOptPara:InvalidPropType',...
26 'Property value ''%s'' of ''%s'' has an incorrect type and is ignored',value,prop);
30 warning(
'MATLAB:ParseOptPara:InvalidPropType',...
31 'Property value %d of ''%s'' has an incorrect type and is ignored',value,prop);
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);