0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % PSD2WF: Input power spectral density (psd) and output a corresponding
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % whitening filter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % DESCRIPTION:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % Input power spectral density (psd) and output a corresponding
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % whitening filter.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % Identification can be performed for a simple system (one psd) or for
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % a two dimensional system (the four elements of the cross-spectral
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % matrix). Continuous or discrete transfer functions are output in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % partial fraction expansion:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % Continuous case:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % r1 rN
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % f(s) = ------- + ... + ------- + d
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % s - p1 s - pN
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % Discrete case:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % r1 rN
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % f(z) = ----------- + ... + ----------- + d
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % 1-p1*z^{-1} 1-pN*z^{-1}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % System identification is performed in frequency domain, the order of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % the model function is automatically chosen by the algorithm on the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % base of the input tolerance condition.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % In the case of simple systems the square root of the psd is fitted
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 % and then the model is stabilized by the application of an all-pass
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % function. Then the inverse is fitted with unstable poles in order to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % output the model for the whitening filter.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 % In the case of two dimensional systems, whitening filter functions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % frequency response is calculated by the eigendecomposition of the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % cross-spectral matrix. Then four models are identified with fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % in frequency domain. If we call these new functions as wf11, wf12,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 % wf21 and wf22, two correlated noisy data series can be whitened by
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % applying (in frequency notation) the matrix relation:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 % / wd1(f) \ / wf11(f) wf12(f) \ / d1(f) \
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 % | | = | |*| |
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 % \ wd2(f) / \ wf21(f) wf22(f) / \ d2(f) /
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % CALL:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 % One dimensional system:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 % [res, poles, dterm] = psd2wf(psd,[],[],[],f,params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 % [res, poles, dterm, mresp] = psd2wf(psd,[],[],[],f,params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % [res, poles, dterm, mresp, rdl] = psd2wf(psd,[],[],[],f,params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 % Two dimensional systems:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 % ostruct = psd2wf(csd11,csd12,csd21,csd22,f,params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % ostruct = psd2wf(csd11,csd12,[],csd22,f,params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 % ostruct = psd2wf(csd11,[],csd21,csd22,f,params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % INPUT:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 % - psd is the power spectral density (1dim case)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 % - csd11, csd12, csd21 and csd22 are the elements of the cross
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 % spectral matrix. If csd12 is left empty, it is calculated as
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 % conj(csd21). If csd21 is left empty, it is calculated as conj(csd12).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 % (2dim case)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % - f: is the corresponding frequencies vector in Hz
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 % - params: is a struct of identification options, the possible values
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 % are:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 % - params.idtp = 0 s-domain identification --> s-domain output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % - params.idtp = 1 z-domain identification --> z-domain output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % params.fullauto = 0 --> Perform a fitting loop as far as the number
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 % of iteration reach Nmaxiter. The order of the fitting function will
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 % be that specified in params.minorder. If params.dterm is setted to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 % 1 the function will fit only with direct term.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 % params.fullauto = 1 --> Parform a full automatic search for the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % transfer function order. The fitting procedure will stop when the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 % stopping condition defined in params.ctp is satisfied. Default
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 % value.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % - params.Nmaxiter = # set the maximum number of fitting steps
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 % performed for each trial function order. Default is 50
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 % - params.minorder = # set the minimum possible function order.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 % Default is 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 % - params.maxorder = # set the maximum possible function order.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 % Default is 25
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 % - params.spolesopt have different behaviours for z and s domains
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 % z-domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 % params.spolesopt = 1 --> use real starting poles
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % params.spolesopt = 2 --> generates complex conjugates poles of the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 % type \alfa e^{j\pi\theta} with \theta = linspace(0,pi,N/2+1).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 % params.spolesopt = 3 --> generates complex conjugates poles of the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 % type \alfa e^{j\pi\theta} with \theta = linspace(0,pi,N/2+2).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 % Default option.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 % s-domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 % params.spolesopt = 1 --> use real starting poles
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 % params.spolesopt = 2 --> use logspaced complex starting poles.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 % Default option
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 % params.spolesopt = 3 --> use linspaced complex starting poles
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 % - params.weightparam = 0 --> use external weights
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 % - params.weightparam = 1 equal weights (one) for each point
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 % - params.weightparam = 2 weight with the inverse of absolute value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 % of fitting data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 % - params.weightparam = 3 weight with square root of the inverse of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 % absolute value of fitting data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 % - params.weightparam = 4 weight with the inverse of the square mean
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 % spread
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % params.extweights = [] --> A vector of externally provided weights.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 % It has to be of the same size of input data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 % - params.plot = 0 --> no plot during fit iteration
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 % - params.plot = 1 --> plot results at each fitting steps. default
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 % value.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % - params.ctp = 'chival' --> check if the value of the Mean Squared
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 % Error is lower than 10^(-1*lsrcond).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 % - params.ctp = 'chivar' --> check if the value of the Mean Squared
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 % Error is lower than 10^(-1*lsrcond) and if the relative variation of mean
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 % squared error is lower than 10^(-1*msevar).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 % - params.ctp = 'lrs' --> check if the log difference between data and
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 % residuals is point by point larger than the value indicated in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 % lsrcond. This mean that residuals are lsrcond order of magnitudes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 % lower than data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 % - params.ctp = 'lrsmse' --> check if the log difference between data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 % and residuals is larger than the value indicated in lsrcond and if
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 % the relative variation of mean squared error is lower than
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 % 10^(-1*msevar).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 % - params.lrscond = # --> set conditioning value for point to point
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 % log residuals difference (params.ctp = 'lsr') and mean log residual
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 % difference (params.ctp = 'mlsrvar'). Default is 2. See help for
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 % stopfit.m for further remarks.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 % - params.msevar = # --> set conditioning value for root mean squared
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 % error variation. This allow to check that the relative variation of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 % mean squared error is lower than 10^(-1*msevar).Default is 7. See
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 % help for stopfit.m for further remarks.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 % - params.fs set the sampling frequency (Hz) useful for z-domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % identification. Default is 1 Hz
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 % - params.usesym = 0 perform double-precision calculation in the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 % eigendecomposition procedure to identify 2dim systems and for poles
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 % stabilization
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 % - params.usesym = 1 uses symbolic math toolbox variable precision
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 % arithmetic in the eigendecomposition for 2dim system identification
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 % double-precison for poles stabilization
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 % - params.usesym = 2 uses symbolic math toolbox variable precision
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 % arithmetic in the eigendecomposition for 2dim system identification
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 % and for poles stabilization
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 % - params.keepvar = true --> preserve input data variance.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 % - params.keepvar = false --> do not preserve input data variance.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 % - params.vars = [# #] desired data variance. Necessary when
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 % keepvar is set to true.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 % - params.dig = # set the digit precision required for variable
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 % precision arithmetic calculations. Default is 50
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 % params.dterm = 0 --> Try to fit without direct term
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 % params.dterm = 1 --> Try to fit with and without direct term
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 % params.spy = 0 --> Do not display the iteration progression
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 % params.spy = 1 --> Display the iteration progression
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 % OUTPUT:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 % One Dimensional System
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 % - res is the vector of residues.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 % - poles is the vector of poles.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 % - dterm is the direct term (if present).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 % - mresp is the model frequency response.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 % - rdl is the vector of residuals calculated as y - mresp.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 % Two Dimensional System
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 % - ostruct is a structure array with five fields and four elements.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 % Element 1 correspond to wf11 data, element 2 to wf12 data, element 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 % to wf21 data and elemnt 4 to wf22 data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 % - ostruct(n).res --> is the vector of residues.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 % - ostruct(n).poles --> is the vector of poles.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 % - ostruct(n).dterm --> are the wfs direct terms.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 % - ostruct(n).mresp --> are the wfs models freq. responses.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 % - ostruct(n).rdl --> are the residuals vectors.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 % HISTORY: 02-10-2008 L Ferraioli
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 % Creation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 % VERSION: '$Id: psd2wf.m,v 1.30 2010/07/15 17:25:42 luigi Exp $';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 function varargout = psd2wf(csd11,csd12,csd21,csd22,f,params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 utils.helper.msg(utils.const.msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 % Collect inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 % Default input struct
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 defaultparams = struct('idtp',1, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 'Nmaxiter',50, 'minorder',2,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 'maxorder',25, 'spolesopt',2, 'weightparam',1, 'plot',0,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 'ctp','chival','lrscond',2,'msevar',2,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 'fs',1, 'usesym',0, 'dig',50, 'dterm',0, 'spy',0, 'fullauto',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 'extweights', [],'keepvar',false,'vars',[1 1]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 names = {'idtp','Nmaxiter','minorder','maxorder','spolesopt',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 'weightparam','plot','stopfitcond',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 'ctp','lrscond','msevar',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 'fs','usesym','dig','dterm','spy','fullauto','extweights',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 'keepvar','vars'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 % collecting input and default params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 if ~isempty(params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 for jj=1:length(names)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 if isfield(params, names(jj)) && ~isempty(params.(names{1,jj}))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 defaultparams.(names{1,jj}) = params.(names{1,jj});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 % default values for input variables
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 idtp = defaultparams.idtp; % identification type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 Nmaxiter = defaultparams.Nmaxiter; % Number of max iteration in the fitting loop
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 minorder = defaultparams.minorder; % Minimum model order
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 maxorder = defaultparams.maxorder; % Maximum model order
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 spolesopt = defaultparams.spolesopt; % 0, Fit with no complex starting poles (complex poles can be found as fit output). 1 fit with comples starting poles
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 weightparam = defaultparams.weightparam; % Weight 1./abs(y). Admitted values are 0, 1, 2, 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 checking = defaultparams.plot; % Never polt. Admitted values are 0 (No polt ever), 1 (plot at the end), 2 (plot at each step)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 ctp = defaultparams.ctp;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 lrscond = defaultparams.lrscond;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 msevar = defaultparams.msevar;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 fs = defaultparams.fs; % sampling frequency
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 usesym = defaultparams.usesym; % method of calculation for the 2dim wfs calculation from psd
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 dig = defaultparams.dig; % number of digits if VPA calculation is required
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 idt = defaultparams.dterm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 spy = defaultparams.spy;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 autosearch = defaultparams.fullauto;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 extweights = defaultparams.extweights;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 kv = defaultparams.keepvar;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 vars = defaultparams.vars;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 % Assign proper values to the control variables for symbolic calculations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 switch usesym
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 case 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 eigsym = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 allsym = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 case 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 eigsym = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 allsym = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 case 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 eigsym = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 allsym = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 % Checking inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 [a,b] = size(csd11);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 if a < b % shifting to column
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 csd11 = csd11.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 if isempty(csd12)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 csd12 = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 [a,b] = size(csd12);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 if a < b % shifting to column
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 csd12 = csd12.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 if isempty(csd21)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 csd21 = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 [a,b] = size(csd21);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 if a < b % shifting to column
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 csd21 = csd21.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 [a,b] = size(csd22);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 if a < b % shifting to column
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 csd22 = csd22.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 [a,b] = size(f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 if a < b % shifting to column
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 f = f.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 % Rescale the models
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 csd11 = csd11 .* fs/2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 csd21 = csd21 .* fs/2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 csd12 = csd12 .* fs/2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 csd22 = csd22 .* fs/2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 % Importing package
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 import utils.math.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 % switching between inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 clear dim
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 % checking for empty csd12, csd21 or csd22
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 if all([isempty(csd12) isempty(csd21) isempty(csd22)])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 dim = '1dim';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 utils.helper.msg(utils.const.msg.PROC1, ' Empty csd12, csd21 and csd22; Performing one dimensional identification on psd ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 dim ='2dim';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 utils.helper.msg(utils.const.msg.PROC1, ' Performing two dimensional identification on csd11, csd12, csd21 and csd22 ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 switch dim
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 case '1dim'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 % switching between continuous and discrete type identification
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 switch idtp
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 case 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 utils.helper.msg(utils.const.msg.PROC1, ' Performing s-domain identification ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 itf = abs(sqrt(csd11)); % input data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 % Fitting WF with unstable poles in s-domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 wf = 1./itf;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 params = struct('spolesopt',spolesopt,'Nmaxiter',Nmaxiter,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 'minorder',minorder,'maxorder',maxorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 'weightparam',weightparam,'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 'stabfit',0,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 'dterm',idt,'spy',spy,'fullauto',autosearch,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 utils.helper.msg(utils.const.msg.PROC1, ' Fitting absolute WF value with unstable model ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 [res,poles,dterm,mresp,rdl,mse] = utils.math.autocfit(wf,f,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 % all pass filtering for poles stabilization
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 if allsym
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering for poles stabilization; symbolic...' )
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 [nr,np,nd,nwf] = utils.math.pfallpsyms(res,poles,dterm,mresp,f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering for poles stabilization' )
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 [nwf,np] = utils.math.pfallps(res,poles,dterm,mresp,f,false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 params = struct('spolesopt',0,'extpoles', np,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 'Nmaxiter',Nmaxiter,'minorder',minorder,'maxorder',maxorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 'weightparam',weightparam,'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 'stabfit',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 'dterm',idt,'spy',spy,'fullauto',autosearch,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF with stable model ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 [res,poles,dterm,mresp,rdl,mse] = utils.math.autocfit(nwf,f,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 % Output data switching between output type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 utils.helper.msg(utils.const.msg.PROC1, ' Output continuous model ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 if nargout == 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 varargout{1} = res;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 varargout{2} = poles;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 varargout{3} = dterm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 elseif nargout == 4
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 varargout{1} = res;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 varargout{2} = poles;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 varargout{3} = dterm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 varargout{4} = mresp;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 elseif nargout == 5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 rdl = abs(sqrt(csd11)) - abs(mresp); % residual respect to original function
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 varargout{1} = res;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 varargout{2} = poles;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 varargout{3} = dterm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 varargout{4} = mresp;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 varargout{5} = rdl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 error(' Unespected number of output. Set 3, 4 or 5! ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 case 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 utils.helper.msg(utils.const.msg.PROC1, ' Performing z-domain identification ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 itf = abs(sqrt(csd11)); % input data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 % Fitting WF with unstable poles
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 wf = 1./itf;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 params = struct('spolesopt',spolesopt, 'Nmaxiter',Nmaxiter, 'minorder',minorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 'maxorder',maxorder, 'weightparam',weightparam, 'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 'stabfit',0,'dterm',idt,'spy',spy,'fullauto',autosearch,'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 utils.helper.msg(utils.const.msg.PROC1, ' Fitting absolute TF value with unstable model ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 [res,poles,dterm,mresp,rdl,mse] = utils.math.autodfit(wf,f,fs,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 % all pass filtering for poles stabilization
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 if allsym
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering for poles stabilization; symbolic...' )
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 [nr,np,nd,nwf] = utils.math.pfallpsymz(res,poles,dterm,mresp,f,fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering for poles stabilization' )
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 [nwf,np] = utils.math.pfallpz(res,poles,dterm,mresp,f,fs,false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 params = struct('spolesopt',0,'extpoles', np,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 'Nmaxiter',Nmaxiter,'minorder',minorder,'maxorder',maxorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 'weightparam',weightparam,'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 'stabfit',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 'dterm',idt,'spy',spy,'fullauto',autosearch,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 [res,poles,dterm,mresp,rdl,mse] = utils.math.autodfit(nwf,f,fs,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 % Output data switching between output type
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 utils.helper.msg(utils.const.msg.PROC1, ' Output z-domain model ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 if nargout == 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 varargout{1} = res;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 varargout{2} = poles;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 varargout{3} = dterm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 elseif nargout == 4
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 varargout{1} = res;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 varargout{2} = poles;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 varargout{3} = dterm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 varargout{4} = mresp;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 elseif nargout == 5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 rdl = abs(sqrt(csd11)) - abs(mresp); % residual respect to original function
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 varargout{1} = res;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 varargout{2} = poles;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 varargout{3} = dterm;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 varargout{4} = mresp;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 varargout{5} = rdl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 error(' Unespected number of output. Set 3, 4 or 5! ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 end % switch idtp
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 case '2dim'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 % switching between continuous and discrete type identification
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 switch idtp
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 case 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 utils.helper.msg(utils.const.msg.PROC1, ' Performing s-domain identification on 2dim system, s-domain output ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 [wf11,wf12,wf21,wf22] = utils.math.eigcsd(csd11,csd12,csd21,csd22,'USESYM',eigsym,'DIG',dig,'OTP','WF','KEEPVAR',kv,'VARS',vars); % input data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 % Shifting to columns
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 [a,b] = size(wf11);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 wf11 = wf11.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 [a,b] = size(wf12);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 wf12 = wf12.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 [a,b] = size(wf21);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 wf21 = wf21.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 [a,b] = size(wf22);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 wf22 = wf22.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 % Collecting wfs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 f1 = [wf11 wf12];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 f2 = [wf21 wf22];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 % Fitting with unstable poles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 params = struct('spolesopt',spolesopt, 'Nmaxiter',Nmaxiter, 'minorder',minorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 'maxorder',maxorder, 'weightparam',weightparam, 'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 'stabfit',0,'dterm',idt,'spy',spy,'fullauto',autosearch,'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF11 and WF21 with unstable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 [res1,poles1,dterm1,mresp1,rdl1,mse1] = utils.math.autocfit(f1,f,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF12 and WF22 with unstable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 [res2,poles2,dterm2,mresp2,rdl2,emse2] = utils.math.autocfit(f2,f,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 % Poles stabilization
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 if allsym
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF11 and WF21, symbolic calc... ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 [nr1,np1,nd1,nf1] = utils.math.pfallpsyms(res1,poles1,dterm1,mresp1,f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 np1 = np1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF12 and WF22, symbolic calc... ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 [nr2,np2,nd2,nf2] = utils.math.pfallpsyms(res2,poles2,dterm2,mresp2,f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 np2 = np2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF11 and WF21 ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 [nf1,np1] = utils.math.pfallps(res1,poles1,dterm1,mresp1,f,false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514 np1 = np1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF12 and WF22 ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 [nf2,np2] = utils.math.pfallps(res2,poles2,dterm2,mresp2,f,false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 np2 = np2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 % Fitting with stable poles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 % Fitting stable WF11 and WF21 with stable poles in s-domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 params = struct('spolesopt',0,'extpoles', np1,'Nmaxiter',Nmaxiter,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 'minorder',minorder,'maxorder',maxorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 'weightparam',weightparam,'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528 'stabfit',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 'dterm',idt,'spy',spy,'fullauto',autosearch,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF11 and WF21 with stable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 [res1,poles1,dterm1,mresp1,rdl1,mse1] = utils.math.autocfit(nf1,f,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536 % Fitting stable WF12 and WF22 with stable poles in s-domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 params = struct('spolesopt',0,'extpoles', np2,'Nmaxiter',Nmaxiter,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539 'minorder',minorder,'maxorder',maxorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 'weightparam',weightparam,'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542 'stabfit',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543 'dterm',idt,'spy',spy,'fullauto',autosearch,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF12 and WF22 with stable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 [res2,poles2,dterm2,mresp2,rdl2,mse2] = utils.math.autocfit(nf2,f,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551 % Output WF model %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 ostruct = struct();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 % Data for wf11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 ostruct(1).res = res1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556 ostruct(1).poles = poles1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557 ostruct(1).dterm = dterm1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558 ostruct(1).mresp = mresp1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 ostruct(1).rdl = rdl1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561 % Data for wf12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562 ostruct(2).res = res1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563 ostruct(2).poles = poles1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 ostruct(2).dterm = dterm1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565 ostruct(2).mresp = mresp1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566 ostruct(2).rdl = rdl1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 % Data for wf21
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570 ostruct(3).res = res2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571 ostruct(3).poles = poles2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572 ostruct(3).dterm = dterm2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573 ostruct(3).mresp = mresp2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574 ostruct(3).rdl = rdl2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576 % Data for wf22
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 ostruct(4).res = res2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578 ostruct(4).poles = poles2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 ostruct(4).dterm = dterm2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 ostruct(4).mresp = mresp2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581 ostruct(4).rdl = rdl2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 % Output data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584 utils.helper.msg(utils.const.msg.PROC1, ' Output continuous models ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585 if nargout == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586 varargout{1} = ostruct;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588 error(' Unespected number of output. Set 1! ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 case 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 utils.helper.msg(utils.const.msg.PROC1, ' Performing z-domain identification on 2dim system')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593 [wf11,wf12,wf21,wf22] = utils.math.eigcsd(csd11,csd12,csd21,csd22,'USESYM',eigsym,'DIG',dig,'OTP','WF','KEEPVAR',kv,'VARS',vars); % input data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595 % Shifting to columns
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596 [a,b] = size(wf11);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598 wf11 = wf11.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 [a,b] = size(wf12);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602 wf12 = wf12.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 [a,b] = size(wf21);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606 wf21 = wf21.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 [a,b] = size(wf22);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609 if a<b
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 wf22 = wf22.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
611 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
612
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
613 % Collecting wfs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
614 f1 = [wf11 wf12];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
615 f2 = [wf21 wf22];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
616
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
617 % Fitting with unstable poles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
618 params = struct('spolesopt',spolesopt, 'Nmaxiter',Nmaxiter, 'minorder',minorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
619 'maxorder',maxorder, 'weightparam',weightparam, 'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
620 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
621 'stabfit',0,'dterm',idt,'spy',spy,'fullauto',autosearch,'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
622
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
623 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
624 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF11 and WF21 with unstable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
625 [res1,poles1,dterm1,mresp1,rdl1,mse1] = utils.math.autodfit(f1,f,fs,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
626
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
627 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF12 and WF22 with unstable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
628 [res2,poles2,dterm2,mresp2,rdl2,mse2] = utils.math.autodfit(f2,f,fs,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
629
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
630
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
631 % Poles stabilization
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
632 if allsym
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
633 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF11 and WF21, symbolic calc... ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
634 [nr1,np1,nd1,nf1] = utils.math.pfallpsymz(res1,poles1,dterm1,mresp1,f,fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
635 np1 = np1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
636 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF12 and WF22, symbolic calc... ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
637 [nr2,np2,nd2,nf2] = utils.math.pfallpsymz(res2,poles2,dterm2,mresp2,f,fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
638 np2 = np2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
639 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
640 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF11 and WF21 ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
641 [nf1,np1] = utils.math.pfallpz(res1,poles1,dterm1,mresp1,f,fs,false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
642 np1 = np1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
643 utils.helper.msg(utils.const.msg.PROC1, ' All pass filtering of WF12 and WF22 ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
644 [nf2,np2] = utils.math.pfallpz(res2,poles2,dterm2,mresp2,f,fs,false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
645 np2 = np2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
646 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
647
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
648 % Fitting with stable poles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
649
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
650 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
651 params = struct('spolesopt',0,'extpoles', np1,'Nmaxiter',Nmaxiter,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
652 'minorder',minorder,'maxorder',maxorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
653 'weightparam',weightparam,'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
654 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
655 'stabfit',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
656 'dterm',idt,'spy',spy,'fullauto',autosearch,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
657 'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
658
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
659 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
660 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF11 and WF21 with stable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
661 [res1,poles1,dterm1,mresp1,rdl1,mse1] = utils.math.autodfit(nf1,f,fs,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
662
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
663 % Fitting stable WF12 and WF22 with stable poles in s-domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
664 % Fitting params
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
665 params = struct('spolesopt',0,'extpoles', np2,'Nmaxiter',Nmaxiter,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
666 'minorder',minorder,'maxorder',maxorder,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
667 'weightparam',weightparam,'plot',checking,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
668 'ctp',ctp,'lrscond',lrscond,'msevar',msevar,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
669 'stabfit',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
670 'dterm',idt,'spy',spy,'fullauto',autosearch,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
671 'extweights',extweights);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
672
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
673 % Fitting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
674 utils.helper.msg(utils.const.msg.PROC1, ' Fitting WF12 and WF22 with stable common poles ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
675 [res2,poles2,dterm2,mresp2,rdl2,mse2] = utils.math.autodfit(nf2,f,fs,params);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
676
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
677
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
678 % Output model %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
679 ostruct = struct();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
680
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
681 % Data for tf11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
682 ostruct(1).res = res1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
683 ostruct(1).poles = poles1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
684 ostruct(1).dterm = dterm1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
685 ostruct(1).mresp = mresp1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
686 ostruct(1).rdl = rdl1(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
687
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
688 % Data for tf12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
689 ostruct(2).res = res1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
690 ostruct(2).poles = poles1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
691 ostruct(2).dterm = dterm1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
692 ostruct(2).mresp = mresp1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
693 ostruct(2).rdl = rdl1(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
694
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
695
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
696 % Data for tf21
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
697 ostruct(3).res = res2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
698 ostruct(3).poles = poles2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
699 ostruct(3).dterm = dterm2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
700 ostruct(3).mresp = mresp2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
701 ostruct(3).rdl = rdl2(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
702
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
703
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
704 % Data for tf22
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
705 ostruct(4).res = res2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
706 ostruct(4).poles = poles2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
707 ostruct(4).dterm = dterm2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
708 ostruct(4).mresp = mresp2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
709 ostruct(4).rdl = rdl2(:,2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
710
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
711 % Output data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
712 utils.helper.msg(utils.const.msg.PROC1, ' Output discrete models ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
713 if nargout == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
714 varargout{1} = ostruct;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
715 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
716 error(' Unespected number of output. Set 1! ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
717 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
718
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
719 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
720 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
721
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
722 % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|