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