Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/buildParamPlist.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % BUILDPARAMPLIST builds paramerter plists for the ssm params field. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: BUILDPARAMPLIST builds paramerter plists for the ssm params | |
5 % field. | |
6 % | |
7 % CALL: pl = bode(names, values, descriptions, units, pl) | |
8 % | |
9 % INPUTS: | |
10 % 'names' - (array of) char | |
11 % 'values' - double array of same size | |
12 % 'description' - cellstr of same size | |
13 % 'pl' - plist containing optionnal fields 'min', 'max', 'sigma', | |
14 % double arrays of same size | |
15 % | |
16 % OUTPUTS: | |
17 % | |
18 % 'pl' - plist of ssm parameters. | |
19 % | |
20 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'buildParamPlist')">Parameters Description</a> | |
21 % | |
22 % VERSION: $Id: buildParamPlist.m,v 1.9 2011/04/08 08:56:22 hewitson Exp $ | |
23 % | |
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
25 | |
26 function varargout = buildParamPlist(varargin) | |
27 %% starting initial checks | |
28 | |
29 | |
30 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]); | |
31 | |
32 names = varargin{1}; | |
33 value = varargin{2}; | |
34 description = varargin{3}; | |
35 units = varargin{4}; | |
36 pl = varargin{5}; | |
37 | |
38 | |
39 %% checking for fields class | |
40 if isa(names, 'char') | |
41 names = {names}; | |
42 elseif ~iscellstr(names) | |
43 error('error because names must either be a cellstr or a char') | |
44 end | |
45 Nparams = numel(names); | |
46 | |
47 if ~isa(value, 'double') && ~isempty(value) | |
48 error('error because values must be a double') | |
49 end | |
50 | |
51 if isa(description, 'char') | |
52 description = {description}; | |
53 elseif ~iscellstr(description) && ~isempty(description) | |
54 error('error because description must either be a cellstr or a char') | |
55 end | |
56 | |
57 if ~isa(units, 'unit') && ~isempty(units) | |
58 error('error because units must be a unit') | |
59 end | |
60 | |
61 if ~isa(pl, 'plist') && ~isempty(pl) | |
62 error('error because pl must be a plist') | |
63 end | |
64 | |
65 %% checking for empty fields or retrieving data | |
66 if isempty(units) | |
67 dounits = false; | |
68 else | |
69 dounits = true; | |
70 if ~( Nparams==numel(units)) | |
71 error('error because names and units are not the same length') | |
72 end | |
73 end | |
74 | |
75 if isempty(description) | |
76 dodescription = false; | |
77 else | |
78 dodescription = true; | |
79 if ~ ( Nparams==numel(description)) | |
80 error('error because names and description are not the same length') | |
81 end | |
82 end | |
83 | |
84 if isempty(value) | |
85 value = NaN(1,Nparams); | |
86 else | |
87 if ~ ( Nparams==numel(value)) | |
88 error('error because names and value are not the same length') | |
89 end | |
90 end | |
91 | |
92 domax = false; | |
93 domin = false; | |
94 dosigma = false; | |
95 if ~isempty(pl) | |
96 if isparam(pl, 'max') | |
97 max = find(pl, 'max'); | |
98 domax = true; | |
99 if ~ ( Nparams==numel(max)) | |
100 error('error because names and max are not the same length') | |
101 end | |
102 end | |
103 if isparam(pl, 'min') | |
104 min = find(pl, 'min'); | |
105 domin = true; | |
106 if ~ ( Nparams==numel(min)) | |
107 error('error because names and min are not the same length') | |
108 end | |
109 end | |
110 if isparam(pl, 'sigma') | |
111 sigma = find(pl, 'sigma'); | |
112 dosigma = true; | |
113 if ~ ( Nparams==numel(sigma)) | |
114 error('error because names and variance are not the same length') | |
115 end | |
116 end | |
117 end | |
118 | |
119 | |
120 %% building plist | |
121 pl = plist(); | |
122 for ii=1:numel(names) | |
123 if dodescription | |
124 pli = plist({names{ii} description{ii}}, value(ii)); | |
125 else | |
126 pli = plist(names{ii}, value(ii)); | |
127 end | |
128 if domax | |
129 pli.setPropertyForKey(names{ii},'max',max(ii) ); | |
130 end | |
131 if domin | |
132 pli.setPropertyForKey(names{ii},'min',min(ii) ); | |
133 end | |
134 if dosigma | |
135 pli.setPropertyForKey(names{ii},'sigma',sigma(ii) ); | |
136 end | |
137 if dounits | |
138 pli.setPropertyForKey(names{ii},'units',units(ii) ); | |
139 end | |
140 pl.append(pli); | |
141 end | |
142 | |
143 varargout{1} = pl; | |
144 end | |
145 |