comparison m-toolbox/test/utils/test_linfitsvd_1.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 % test utils.math.linifitsvd
2 %
3 % 05-06-2009 L Ferraioli
4 % CREATION
5 %
6 %
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 % $Id: mdc3_exp3_loop_v3.m,v 1.2 2009/09/24 09:48:12 luigi Exp $
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10
11 %% Loading data
12
13 % load cell arrays with parameters names and values
14
15 fprintf('===== loading data... =====\n')
16
17 % laod parnames and values
18 load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\parnames_10perc.mat
19 load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\exp3_2_10perc_nomvalues.mat
20 load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\exp3_2_10perc_truevalues.mat
21 % load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\usedparams_10perc.mat
22
23
24 % set ordered used parameters
25 % usedparams = {'dH','dsH','dS11','dS1D','dSD1','dSDD','dh1','dsh1',...
26 % 'dh2','dsh2','dx1','dx2'};
27 usedparams = {'dH','dsH','dS11','dS1D','dSD1','dSDD',...
28 'dh2','dsh2','dx1','dx2'};
29
30 %% load Coloring filters
31
32 fprintf('===== loading coloring filters... =====\n')
33
34 cf11 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF11.mat');
35 cf11.setName;
36 cf12 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF12.mat');
37 cf12.setName;
38 cf21 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF21.mat');
39 cf21.setName;
40 cf22 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_CF22.mat');
41 cf22.setName;
42
43 %% load Whitening filters
44
45 fprintf('===== loading whitening filters... =====\n')
46
47 wf11 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF11.mat');
48 wf11.setName;
49 wf12 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF12.mat');
50 wf12.setName;
51 wf21 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF21.mat');
52 wf21.setName;
53 wf22 = miir('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Filters\exp1_WF22.mat');
54 wf22.setName;
55
56 %% get non-linear response model
57 % the model is non-linear in the parameter dependence
58 fprintf('===== Get TF Model... =====\n')
59
60 % H is a 2x2 matrix of smodels representing the transfer function from
61 % controllers guidance to ifo output
62 H = matrix(plist('built-in','mdc3_ifo2ifo_v2'));
63
64 %% Get derivative models
65 % those are derivatives of the model with respect to the parameters
66
67 fprintf('===== Get derivative models... =====\n')
68
69 % differentiate respect to the stiffness
70 T_dH = copy(H,1);
71 T_dsH = copy(H,1);
72
73 T_dS11 = copy(H,1);
74 T_dS1D = copy(H,1);
75 T_dSD1 = copy(H,1);
76 T_dSDD = copy(H,1);
77
78 T_dh1 = copy(H,1);
79 T_dsh1 = copy(H,1);
80
81 T_dh2 = copy(H,1);
82 T_dsh2 = copy(H,1);
83
84 T_dx1 = copy(H,1);
85 T_dx2 = copy(H,1);
86
87 % differentiate respect to the stiffness
88 for ii = 1:numel(H.objs)
89 T_dH.objs(ii) = diff(H.objs(ii),'dH');
90 T_dsH.objs(ii) = diff(H.objs(ii),'dsH');
91
92 T_dS11.objs(ii) = diff(H.objs(ii),'dS11');
93 T_dS1D.objs(ii) = diff(H.objs(ii),'dS1D');
94 T_dSD1.objs(ii) = diff(H.objs(ii),'dSD1');
95 T_dSDD.objs(ii) = diff(H.objs(ii),'dSDD');
96
97 T_dh1.objs(ii) = diff(H.objs(ii),'dh1');
98 T_dsh1.objs(ii) = diff(H.objs(ii),'dsh1');
99
100 T_dh2.objs(ii) = diff(H.objs(ii),'dh2');
101 T_dsh2.objs(ii) = diff(H.objs(ii),'dsh2');
102
103 T_dx1.objs(ii) = diff(H.objs(ii),'dx1');
104 T_dx2.objs(ii) = diff(H.objs(ii),'dx2');
105 end
106
107 %% *** Signals generation ***
108
109 % ************************************************************************
110 % The output of each experiment is generated according to the following
111 % scheme
112 % i) generation of the output of the system to a given input
113 % ii) generation of the output noise time series
114 % iii) output signals and noise are added to get the final output signals
115 % for each experiment
116 % ************************************************************************
117
118 %% load input signal
119 % load input data series in accordance to TN 3045
120
121 fprintf('===== Loading input signals... =====\n')
122
123 oi1 = ao('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\signals_noise\exp1_1_oi1.mat');
124 oi1.setName;
125 oi1.setYunits('m');
126 oid = ao('C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\signals_noise\exp1_2_oid.mat');
127 oid.setName;
128 oid.setYunits('m');
129
130 %% get signals - true values
131
132 fprintf('===== get true values... =====\n')
133
134 % calculate the response of the system for the first two experiments of TN
135 % 3045
136 % Exp 3.1 input on first channel, no input on the differential channel
137 % Exp 3.2 no input on the first channel, input on the differential channel
138 % Output is always taken from both channels
139
140 % get response with true params
141 for ii = 1:numel(H.objs)
142 H.objs(ii).setParams(parnames,exp3_truevalues);
143 end
144
145 s11 = fftfilt(oi1,H.objs(1,1));
146 s12 = fftfilt(oid,H.objs(1,2));
147 s21 = fftfilt(oi1,H.objs(2,1));
148 s22 = fftfilt(oid,H.objs(2,2));
149
150 % get output signals for exp 3.1
151 s1_exp_3_1 = s11;
152 s1_exp_3_1.setName;
153 sd_exp_3_1 = s21;
154 sd_exp_3_1.setName;
155
156 % get output signals for exp 3.2
157 s1_exp_3_2 = s12;
158 s1_exp_3_2.setName;
159 sd_exp_3_2 = s22;
160 sd_exp_3_2.setName;
161
162 %% Adding noise to signals
163
164 fprintf('===== adding noise to signals... =====\n')
165
166 % get params
167 Nsecs = s1_exp_3_1.nsecs;
168 fs = s1_exp_3_1.fs;
169 plcf = plist('bank','parallel');
170
171 % starting noise generation exp1.1
172 a1_exp_3_1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
173 a2_exp_3_1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
174
175 % coloring noise exp 1.1
176 na1_exp_3_1 = filter(a1_exp_3_1,cf11,plcf) + filter(a2_exp_3_1,cf12,plcf);
177 na2_exp_3_1 = filter(a1_exp_3_1,cf21,plcf) + filter(a2_exp_3_1,cf22,plcf);
178
179 % starting noise generation exp 1.2
180 a1_exp_3_2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
181 a2_exp_3_2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs));
182
183 % coloring noise exp 1.2
184 na1_exp_3_2 = filter(a1_exp_3_2,cf11,plcf) + filter(a2_exp_3_2,cf12,plcf);
185 na2_exp_3_2 = filter(a1_exp_3_2,cf21,plcf) + filter(a2_exp_3_2,cf22,plcf);
186
187 % adding noise to signals, These signals are the output of our experiments
188 o1_exp_3_1 = s1_exp_3_1 + na1_exp_3_1;
189 od_exp_3_1 = sd_exp_3_1 + na2_exp_3_1;
190
191 o1_exp_3_2 = s1_exp_3_2 + na1_exp_3_2;
192 od_exp_3_2 = sd_exp_3_2 + na2_exp_3_2;
193
194
195
196 % %% plot
197 %
198 % iplot(o1_exp_3_1,plist('Legends', {'i1->o1'}))
199 % iplot(od_exp_3_1,plist('Legends', {'i1->od'}))
200 % iplot(o1_exp_3_2,plist('Legends', {'id->o1'}))
201 % iplot(od_exp_3_2,plist('Legends', {'id->od'}))
202
203 %% Run loop to get parameters
204
205 % ************************************************************************
206 % The linear fit scheme is the following
207 %
208 % y - y0 = sum( p(dH/dp) )
209 %
210 % y is the output data series
211 % y0 is the calculated nominal response
212 % dH/dp are derivatives of model with respect to parameters
213 % p are the parameters
214 %
215 % If a whitening step is required it can be applied as:
216 %
217 % WF( y - y0 ) = WF( sum( p(dH/dp) ) )
218 % = sum( p WF( dH/dp ) )
219 %
220 % ************************************************************************
221 % Fit loop for parameters extraction
222 %
223 % 1) Response of the derivatives of the model with respect to the
224 % parameters is calculated according to the parameters nominal values.
225 % These represent what I call, fit basis.
226 % 2) Fit basis is whitened in order to consider the effect of the whitening
227 % filter on data.
228 % 3) Fit matrices are then built up from fit basis.
229 % 4) Ground experiments results are input as additional information on some
230 % parameters.
231 % 5) Nominal system response is calculated.
232 % 6) Nominal response is subtracted from output signals for the different
233 % experiments.
234 % 7) Whitening filter is applied to the difference y - y0.
235 % 8) Linear fit is performed, information from different experiments and
236 % ground experiments is joined to increase fit accuracy.
237 % 9) The values of the parameters obtained are used to calculate a new set
238 % of nominal values which are used in the following loop.
239 % ************************************************************************
240
241 % run a loop to estimate system parameters
242 fprintf('===== start loop iteration... =====\n')
243
244
245 N = 1; % Number of iterations
246
247
248 % f = logspace(-5,log10(fs/2),300).';
249
250 plcf = plist('bank','parallel');
251
252 % init storage struct
253 mdc3_exp3_loop_results = struct('a',cell(1,N),...
254 'Ca',cell(1,N),...
255 'Corra',cell(1,N),...
256 'Vu',cell(1,N),...
257 'bu',cell(1,N),...
258 'Cbu',cell(1,N),...
259 'mse',cell(1,N),...
260 'params',cell(1,N));
261
262
263
264 % for ii = 1:N
265
266 fprintf('===== iter %s =====\n',num2str(1))
267
268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
269
270 % get template
271 fprintf('===== Get template - iter %s =====\n',num2str(1))
272
273 % set nominal values
274 for jj = 1:numel(H.objs)
275 T_dH.objs(jj).setParams(parnames,exp3_nomvalues);
276 T_dsH.objs(jj).setParams(parnames,exp3_nomvalues);
277 T_dS11.objs(jj).setParams(parnames,exp3_nomvalues);
278 T_dS1D.objs(jj).setParams(parnames,exp3_nomvalues);
279 T_dSD1.objs(jj).setParams(parnames,exp3_nomvalues);
280 T_dSDD.objs(jj).setParams(parnames,exp3_nomvalues);
281 T_dh1.objs(jj).setParams(parnames,exp3_nomvalues);
282 T_dsh1.objs(jj).setParams(parnames,exp3_nomvalues);
283 T_dh2.objs(jj).setParams(parnames,exp3_nomvalues);
284 T_dsh2.objs(jj).setParams(parnames,exp3_nomvalues);
285 T_dx1.objs(jj).setParams(parnames,exp3_nomvalues);
286 T_dx2.objs(jj).setParams(parnames,exp3_nomvalues);
287 end
288
289 % get response for dH
290 ds11 = fftfilt(oi1,T_dH.objs(1,1));
291 ds12 = fftfilt(oid,T_dH.objs(1,2));
292 ds21 = fftfilt(oi1,T_dH.objs(2,1));
293 ds22 = fftfilt(oid,T_dH.objs(2,2));
294
295 dH_1_exp_3_1 = ds11;
296 dH_1_exp_3_1.setName;
297 dH_12_exp_3_1 = ds21;
298 dH_12_exp_3_1.setName;
299 dH_1_exp_3_2 = ds12;
300 dH_1_exp_3_2.setName;
301 dH_12_exp_3_2 = ds22;
302 dH_12_exp_3_2.setName;
303
304
305 % get response for dsH
306 ds11 = fftfilt(oi1,T_dsH.objs(1,1));
307 ds12 = fftfilt(oid,T_dsH.objs(1,2));
308 ds21 = fftfilt(oi1,T_dsH.objs(2,1));
309 ds22 = fftfilt(oid,T_dsH.objs(2,2));
310
311 dsH_1_exp_3_1 = ds11;
312 dsH_1_exp_3_1.setName;
313 dsH_12_exp_3_1 = ds21;
314 dsH_12_exp_3_1.setName;
315 dsH_1_exp_3_2 = ds12;
316 dsH_1_exp_3_2.setName;
317 dsH_12_exp_3_2 = ds22;
318 dsH_12_exp_3_2.setName;
319
320 % get response for dS11
321 ds11 = fftfilt(oi1,T_dS11.objs(1,1));
322 ds12 = fftfilt(oid,T_dS11.objs(1,2));
323 ds21 = fftfilt(oi1,T_dS11.objs(2,1));
324 ds22 = fftfilt(oid,T_dS11.objs(2,2));
325
326 dS11_1_exp_3_1 = ds11;
327 dS11_1_exp_3_1.setName;
328 dS11_12_exp_3_1 = ds21;
329 dS11_12_exp_3_1.setName;
330 dS11_1_exp_3_2 = ds12;
331 dS11_1_exp_3_2.setName;
332 dS11_12_exp_3_2 = ds22;
333 dS11_12_exp_3_2.setName;
334
335 % get response for dS1D
336 ds11 = fftfilt(oi1,T_dS1D.objs(1,1));
337 ds12 = fftfilt(oid,T_dS1D.objs(1,2));
338 ds21 = fftfilt(oi1,T_dS1D.objs(2,1));
339 ds22 = fftfilt(oid,T_dS1D.objs(2,2));
340
341 dS1D_1_exp_3_1 = ds11;
342 dS1D_1_exp_3_1.setName;
343 dS1D_12_exp_3_1 = ds21;
344 dS1D_12_exp_3_1.setName;
345 dS1D_1_exp_3_2 = ds12;
346 dS1D_1_exp_3_2.setName;
347 dS1D_12_exp_3_2 = ds22;
348 dS1D_12_exp_3_2.setName;
349
350
351 % get response for SD1
352 ds11 = fftfilt(oi1,T_dSD1.objs(1,1));
353 ds12 = fftfilt(oid,T_dSD1.objs(1,2));
354 ds21 = fftfilt(oi1,T_dSD1.objs(2,1));
355 ds22 = fftfilt(oid,T_dSD1.objs(2,2));
356
357 dSD1_1_exp_3_1 = ds11;
358 dSD1_1_exp_3_1.setName;
359 dSD1_12_exp_3_1 = ds21;
360 dSD1_12_exp_3_1.setName;
361 dSD1_1_exp_3_2 = ds12;
362 dSD1_1_exp_3_2.setName;
363 dSD1_12_exp_3_2 = ds22;
364 dSD1_12_exp_3_2.setName;
365
366 % get response for SDD
367 ds11 = fftfilt(oi1,T_dSDD.objs(1,1));
368 ds12 = fftfilt(oid,T_dSDD.objs(1,2));
369 ds21 = fftfilt(oi1,T_dSDD.objs(2,1));
370 ds22 = fftfilt(oid,T_dSDD.objs(2,2));
371
372 dSDD_1_exp_3_1 = ds11;
373 dSDD_1_exp_3_1.setName;
374 dSDD_12_exp_3_1 = ds21;
375 dSDD_12_exp_3_1.setName;
376 dSDD_1_exp_3_2 = ds12;
377 dSDD_1_exp_3_2.setName;
378 dSDD_12_exp_3_2 = ds22;
379 dSDD_12_exp_3_2.setName;
380
381 % get response for dh1
382 ds11 = fftfilt(oi1,T_dh1.objs(1,1));
383 ds12 = fftfilt(oid,T_dh1.objs(1,2));
384 ds21 = fftfilt(oi1,T_dh1.objs(2,1));
385 ds22 = fftfilt(oid,T_dh1.objs(2,2));
386
387 dh1_1_exp_3_1 = ds11;
388 dh1_1_exp_3_1.setName;
389 dh1_12_exp_3_1 = ds21;
390 dh1_12_exp_3_1.setName;
391 dh1_1_exp_3_2 = ds12;
392 dh1_1_exp_3_2.setName;
393 dh1_12_exp_3_2 = ds22;
394 dh1_12_exp_3_2.setName;
395
396 % get response for dsh1
397 ds11 = fftfilt(oi1,T_dsh1.objs(1,1));
398 ds12 = fftfilt(oid,T_dsh1.objs(1,2));
399 ds21 = fftfilt(oi1,T_dsh1.objs(2,1));
400 ds22 = fftfilt(oid,T_dsh1.objs(2,2));
401
402 dsh1_1_exp_3_1 = ds11;
403 dsh1_1_exp_3_1.setName;
404 dsh1_12_exp_3_1 = ds21;
405 dsh1_12_exp_3_1.setName;
406 dsh1_1_exp_3_2 = ds12;
407 dsh1_1_exp_3_2.setName;
408 dsh1_12_exp_3_2 = ds22;
409 dsh1_12_exp_3_2.setName;
410
411
412 % get response for dh2
413 ds11 = fftfilt(oi1,T_dh2.objs(1,1));
414 ds12 = fftfilt(oid,T_dh2.objs(1,2));
415 ds21 = fftfilt(oi1,T_dh2.objs(2,1));
416 ds22 = fftfilt(oid,T_dh2.objs(2,2));
417
418 dh2_1_exp_3_1 = ds11;
419 dh2_1_exp_3_1.setName;
420 dh2_12_exp_3_1 = ds21;
421 dh2_12_exp_3_1.setName;
422 dh2_1_exp_3_2 = ds12;
423 dh2_1_exp_3_2.setName;
424 dh2_12_exp_3_2 = ds22;
425 dh2_12_exp_3_2.setName;
426
427 % get response for dsh2
428 ds11 = fftfilt(oi1,T_dsh2.objs(1,1));
429 ds12 = fftfilt(oid,T_dsh2.objs(1,2));
430 ds21 = fftfilt(oi1,T_dsh2.objs(2,1));
431 ds22 = fftfilt(oid,T_dsh2.objs(2,2));
432
433 dsh2_1_exp_3_1 = ds11;
434 dsh2_1_exp_3_1.setName;
435 dsh2_12_exp_3_1 = ds21;
436 dsh2_12_exp_3_1.setName;
437 dsh2_1_exp_3_2 = ds12;
438 dsh2_1_exp_3_2.setName;
439 dsh2_12_exp_3_2 = ds22;
440 dsh2_12_exp_3_2.setName;
441
442 % get response for dx1
443 ds11 = fftfilt(oi1,T_dx1.objs(1,1));
444 ds12 = fftfilt(oid,T_dx1.objs(1,2));
445 ds21 = fftfilt(oi1,T_dx1.objs(2,1));
446 ds22 = fftfilt(oid,T_dx1.objs(2,2));
447
448 dx1_1_exp_3_1 = ds11;
449 dx1_1_exp_3_1.setName;
450 dx1_12_exp_3_1 = ds21;
451 dx1_12_exp_3_1.setName;
452 dx1_1_exp_3_2 = ds12;
453 dx1_1_exp_3_2.setName;
454 dx1_12_exp_3_2 = ds22;
455 dx1_12_exp_3_2.setName;
456
457
458 % get response for dx2
459 ds11 = fftfilt(oi1,T_dx2.objs(1,1));
460 ds12 = fftfilt(oid,T_dx2.objs(1,2));
461 ds21 = fftfilt(oi1,T_dx2.objs(2,1));
462 ds22 = fftfilt(oid,T_dx2.objs(2,2));
463
464 dx2_1_exp_3_1 = ds11;
465 dx2_1_exp_3_1.setName;
466 dx2_12_exp_3_1 = ds21;
467 dx2_12_exp_3_1.setName;
468 dx2_1_exp_3_2 = ds12;
469 dx2_1_exp_3_2.setName;
470 dx2_12_exp_3_2 = ds22;
471 dx2_12_exp_3_2.setName;
472
473 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
474
475 % do whitening on template
476 fprintf('===== do whitening on template - iter %s =====\n',num2str(1))
477
478 plwf = plist('bank','parallel');
479
480 dH_1w_exp_3_1 = filter(dH_1_exp_3_1,wf11,plwf) + filter(dH_12_exp_3_1,wf12,plwf);
481 dH_12w_exp_3_1 = filter(dH_1_exp_3_1,wf21,plwf) + filter(dH_12_exp_3_1,wf22,plwf);
482
483 dsH_1w_exp_3_1 = filter(dsH_1_exp_3_1,wf11,plwf) + filter(dsH_12_exp_3_1,wf12,plwf);
484 dsH_12w_exp_3_1 = filter(dsH_1_exp_3_1,wf21,plwf) + filter(dsH_12_exp_3_1,wf22,plwf);
485
486 dS11_1w_exp_3_1 = filter(dS11_1_exp_3_1,wf11,plwf) + filter(dS11_12_exp_3_1,wf12,plwf);
487 dS11_12w_exp_3_1 = filter(dS11_1_exp_3_1,wf21,plwf) + filter(dS11_12_exp_3_1,wf22,plwf);
488
489 dS1D_1w_exp_3_1 = filter(dS1D_1_exp_3_1,wf11,plwf) + filter(dS1D_12_exp_3_1,wf12,plwf);
490 dS1D_12w_exp_3_1 = filter(dS1D_1_exp_3_1,wf21,plwf) + filter(dS1D_12_exp_3_1,wf22,plwf);
491
492 dSD1_1w_exp_3_1 = filter(dSD1_1_exp_3_1,wf11,plwf) + filter(dSD1_12_exp_3_1,wf12,plwf);
493 dSD1_12w_exp_3_1 = filter(dSD1_1_exp_3_1,wf21,plwf) + filter(dSD1_12_exp_3_1,wf22,plwf);
494
495 dSDD_1w_exp_3_1 = filter(dSDD_1_exp_3_1,wf11,plwf) + filter(dSDD_12_exp_3_1,wf12,plwf);
496 dSDD_12w_exp_3_1 = filter(dSDD_1_exp_3_1,wf21,plwf) + filter(dSDD_12_exp_3_1,wf22,plwf);
497
498 dh1_1w_exp_3_1 = filter(dh1_1_exp_3_1,wf11,plwf) + filter(dh1_12_exp_3_1,wf12,plwf);
499 dh1_12w_exp_3_1 = filter(dh1_1_exp_3_1,wf21,plwf) + filter(dh1_12_exp_3_1,wf22,plwf);
500
501 dsh1_1w_exp_3_1 = filter(dsh1_1_exp_3_1,wf11,plwf) + filter(dsh1_12_exp_3_1,wf12,plwf);
502 dsh1_12w_exp_3_1 = filter(dsh1_1_exp_3_1,wf21,plwf) + filter(dsh1_12_exp_3_1,wf22,plwf);
503
504 dh2_1w_exp_3_1 = filter(dh2_1_exp_3_1,wf11,plwf) + filter(dh2_12_exp_3_1,wf12,plwf);
505 dh2_12w_exp_3_1 = filter(dh2_1_exp_3_1,wf21,plwf) + filter(dh2_12_exp_3_1,wf22,plwf);
506
507 dsh2_1w_exp_3_1 = filter(dsh2_1_exp_3_1,wf11,plwf) + filter(dsh2_12_exp_3_1,wf12,plwf);
508 dsh2_12w_exp_3_1 = filter(dsh2_1_exp_3_1,wf21,plwf) + filter(dsh2_12_exp_3_1,wf22,plwf);
509
510 dx1_1w_exp_3_1 = filter(dx1_1_exp_3_1,wf11,plwf) + filter(dx1_12_exp_3_1,wf12,plwf);
511 dx1_12w_exp_3_1 = filter(dx1_1_exp_3_1,wf21,plwf) + filter(dx1_12_exp_3_1,wf22,plwf);
512
513 dx2_1w_exp_3_1 = filter(dx2_1_exp_3_1,wf11,plwf) + filter(dx2_12_exp_3_1,wf12,plwf);
514 dx2_12w_exp_3_1 = filter(dx2_1_exp_3_1,wf21,plwf) + filter(dx2_12_exp_3_1,wf22,plwf);
515
516 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
517
518 dH_1w_exp_3_2 = filter(dH_1_exp_3_2,wf11,plwf) + filter(dH_12_exp_3_2,wf12,plwf);
519 dH_12w_exp_3_2 = filter(dH_1_exp_3_2,wf21,plwf) + filter(dH_12_exp_3_2,wf22,plwf);
520
521 dsH_1w_exp_3_2 = filter(dsH_1_exp_3_2,wf11,plwf) + filter(dsH_12_exp_3_2,wf12,plwf);
522 dsH_12w_exp_3_2 = filter(dsH_1_exp_3_2,wf21,plwf) + filter(dsH_12_exp_3_2,wf22,plwf);
523
524 dS11_1w_exp_3_2 = filter(dS11_1_exp_3_2,wf11,plwf) + filter(dS11_12_exp_3_2,wf12,plwf);
525 dS11_12w_exp_3_2 = filter(dS11_1_exp_3_2,wf21,plwf) + filter(dS11_12_exp_3_2,wf22,plwf);
526
527 dS1D_1w_exp_3_2 = filter(dS1D_1_exp_3_2,wf11,plwf) + filter(dS1D_12_exp_3_2,wf12,plwf);
528 dS1D_12w_exp_3_2 = filter(dS1D_1_exp_3_2,wf21,plwf) + filter(dS1D_12_exp_3_2,wf22,plwf);
529
530 dSD1_1w_exp_3_2 = filter(dSD1_1_exp_3_2,wf11,plwf) + filter(dSD1_12_exp_3_2,wf12,plwf);
531 dSD1_12w_exp_3_2 = filter(dSD1_1_exp_3_2,wf21,plwf) + filter(dSD1_12_exp_3_2,wf22,plwf);
532
533 dSDD_1w_exp_3_2 = filter(dSDD_1_exp_3_2,wf11,plwf) + filter(dSDD_12_exp_3_2,wf12,plwf);
534 dSDD_12w_exp_3_2 = filter(dSDD_1_exp_3_2,wf21,plwf) + filter(dSDD_12_exp_3_2,wf22,plwf);
535
536 dh1_1w_exp_3_2 = filter(dh1_1_exp_3_2,wf11,plwf) + filter(dh1_12_exp_3_2,wf12,plwf);
537 dh1_12w_exp_3_2 = filter(dh1_1_exp_3_2,wf21,plwf) + filter(dh1_12_exp_3_2,wf22,plwf);
538
539 dsh1_1w_exp_3_2 = filter(dsh1_1_exp_3_2,wf11,plwf) + filter(dsh1_12_exp_3_2,wf12,plwf);
540 dsh1_12w_exp_3_2 = filter(dsh1_1_exp_3_2,wf21,plwf) + filter(dsh1_12_exp_3_2,wf22,plwf);
541
542 dh2_1w_exp_3_2 = filter(dh2_1_exp_3_2,wf11,plwf) + filter(dh2_12_exp_3_2,wf12,plwf);
543 dh2_12w_exp_3_2 = filter(dh2_1_exp_3_2,wf21,plwf) + filter(dh2_12_exp_3_2,wf22,plwf);
544
545 dsh2_1w_exp_3_2 = filter(dsh2_1_exp_3_2,wf11,plwf) + filter(dsh2_12_exp_3_2,wf12,plwf);
546 dsh2_12w_exp_3_2 = filter(dsh2_1_exp_3_2,wf21,plwf) + filter(dsh2_12_exp_3_2,wf22,plwf);
547
548 dx1_1w_exp_3_2 = filter(dx1_1_exp_3_2,wf11,plwf) + filter(dx1_12_exp_3_2,wf12,plwf);
549 dx1_12w_exp_3_2 = filter(dx1_1_exp_3_2,wf21,plwf) + filter(dx1_12_exp_3_2,wf22,plwf);
550
551 dx2_1w_exp_3_2 = filter(dx2_1_exp_3_2,wf11,plwf) + filter(dx2_12_exp_3_2,wf12,plwf);
552 dx2_12w_exp_3_2 = filter(dx2_1_exp_3_2,wf21,plwf) + filter(dx2_12_exp_3_2,wf22,plwf);
553
554
555 %%% Build fit matrices %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 fprintf('===== Build fit matrices - iter %s =====\n',num2str(1))
557
558 % init data struct
559 exps = struct();
560
561 % exp 3.1 ch1
562 dHw_exp_3_1 = [dH_1w_exp_3_1.y];
563 dsHw_exp_3_1 = [dsH_1w_exp_3_1.y];
564 dS11w_exp_3_1 = [dS11_1w_exp_3_1.y];
565 dS1Dw_exp_3_1 = [dS1D_1w_exp_3_1.y];
566 dSD1w_exp_3_1 = [dSD1_1w_exp_3_1.y];
567 dSDDw_exp_3_1 = [dSDD_1w_exp_3_1.y];
568 dh1w_exp_3_1 = [dh1_1w_exp_3_1.y];
569 dsh1w_exp_3_1 = [dsh1_1w_exp_3_1.y];
570 dh2w_exp_3_1 = [dh2_1w_exp_3_1.y];
571 dsh2w_exp_3_1 = [dsh2_1w_exp_3_1.y];
572 dx1w_exp_3_1 = [dx1_1w_exp_3_1.y];
573 dx2w_exp_3_1 = [dx2_1w_exp_3_1.y];
574
575 K1_exp_3_1 = [dHw_exp_3_1 dsHw_exp_3_1 dS11w_exp_3_1 dS1Dw_exp_3_1...
576 dSD1w_exp_3_1 dSDDw_exp_3_1...
577 dh2w_exp_3_1 dsh2w_exp_3_1 dx1w_exp_3_1 dx2w_exp_3_1];
578
579
580 % cut the first 100 samples to remove WF transients effects
581 K1_exp_3_1(1:100,:) = [];
582 % fill struct basis
583 exps(1).fitbasis = K1_exp_3_1;
584
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586 % exp 3.1 ch12
587 dHw_exp_3_1 = [dH_12w_exp_3_1.y];
588 dsHw_exp_3_1 = [dsH_12w_exp_3_1.y];
589 dS11w_exp_3_1 = [dS11_12w_exp_3_1.y];
590 dS1Dw_exp_3_1 = [dS1D_12w_exp_3_1.y];
591 dSD1w_exp_3_1 = [dSD1_12w_exp_3_1.y];
592 dSDDw_exp_3_1 = [dSDD_12w_exp_3_1.y];
593 dh1w_exp_3_1 = [dh1_12w_exp_3_1.y];
594 dsh1w_exp_3_1 = [dsh1_12w_exp_3_1.y];
595 dh2w_exp_3_1 = [dh2_12w_exp_3_1.y];
596 dsh2w_exp_3_1 = [dsh2_12w_exp_3_1.y];
597 dx1w_exp_3_1 = [dx1_12w_exp_3_1.y];
598 dx2w_exp_3_1 = [dx2_12w_exp_3_1.y];
599
600 K12_exp_3_1 = [dHw_exp_3_1 dsHw_exp_3_1 dS11w_exp_3_1 dS1Dw_exp_3_1...
601 dSD1w_exp_3_1 dSDDw_exp_3_1...
602 dh2w_exp_3_1 dsh2w_exp_3_1 dx1w_exp_3_1 dx2w_exp_3_1];
603
604 clear dHw_exp_3_1 dsHw_exp_3_1 dS11w_exp_3_1 dS1Dw_exp_3_1 dSD1w_exp_3_1...
605 dSDDw_exp_3_1 dh1w_exp_3_1 dsh1w_exp_3_1 dh2w_exp_3_1 dsh2w_exp_3_1...
606 dx1w_exp_3_1 dx2w_exp_3_1
607
608 % cut the first 100 samples to remove WF transients effects
609 K12_exp_3_1(1:100,:) = [];
610 % fill struct basis
611 exps(2).fitbasis = K12_exp_3_1;
612
613 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
614 % exp 3.2 ch1
615 dHw_exp_3_2 = [dH_1w_exp_3_2.y];
616 dsHw_exp_3_2 = [dsH_1w_exp_3_2.y];
617 dS11w_exp_3_2 = [dS11_1w_exp_3_2.y];
618 dS1Dw_exp_3_2 = [dS1D_1w_exp_3_2.y];
619 dSD1w_exp_3_2 = [dSD1_1w_exp_3_2.y];
620 dSDDw_exp_3_2 = [dSDD_1w_exp_3_2.y];
621 dh1w_exp_3_2 = [dh1_1w_exp_3_2.y];
622 dsh1w_exp_3_2 = [dsh1_1w_exp_3_2.y];
623 dh2w_exp_3_2 = [dh2_1w_exp_3_2.y];
624 dsh2w_exp_3_2 = [dsh2_1w_exp_3_2.y];
625 dx1w_exp_3_2 = [dx1_1w_exp_3_2.y];
626 dx2w_exp_3_2 = [dx2_1w_exp_3_2.y];
627
628 K1_exp_3_2 = [dHw_exp_3_2 dsHw_exp_3_2 dS11w_exp_3_2 dS1Dw_exp_3_2...
629 dSD1w_exp_3_2 dSDDw_exp_3_2...
630 dh2w_exp_3_2 dsh2w_exp_3_2 dx1w_exp_3_2 dx2w_exp_3_2];
631
632
633 % cut the first 100 samples to remove WF transients effects
634 K1_exp_3_2(1:100,:) = [];
635 % fill struct basis
636 exps(3).fitbasis = K1_exp_3_2;
637
638 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
639 % exp 3.2 ch12
640 dHw_exp_3_2 = [dH_12w_exp_3_2.y];
641 dsHw_exp_3_2 = [dsH_12w_exp_3_2.y];
642 dS11w_exp_3_2 = [dS11_12w_exp_3_2.y];
643 dS1Dw_exp_3_2 = [dS1D_12w_exp_3_2.y];
644 dSD1w_exp_3_2 = [dSD1_12w_exp_3_2.y];
645 dSDDw_exp_3_2 = [dSDD_12w_exp_3_2.y];
646 dh1w_exp_3_2 = [dh1_12w_exp_3_2.y];
647 dsh1w_exp_3_2 = [dsh1_12w_exp_3_2.y];
648 dh2w_exp_3_2 = [dh2_12w_exp_3_2.y];
649 dsh2w_exp_3_2 = [dsh2_12w_exp_3_2.y];
650 dx1w_exp_3_2 = [dx1_12w_exp_3_2.y];
651 dx2w_exp_3_2 = [dx2_12w_exp_3_2.y];
652
653 K12_exp_3_2 = [dHw_exp_3_2 dsHw_exp_3_2 dS11w_exp_3_2 dS1Dw_exp_3_2...
654 dSD1w_exp_3_2 dSDDw_exp_3_2...
655 dh2w_exp_3_2 dsh2w_exp_3_2 dx1w_exp_3_2 dx2w_exp_3_2];
656
657 clear dHw_exp_3_2 dsHw_exp_3_2 dS11w_exp_3_2 dS1Dw_exp_3_2...
658 dSD1w_exp_3_2 dSDDw_exp_3_2 dh1w_exp_3_2 dsh1w_exp_3_2...
659 dh2w_exp_3_2 dsh2w_exp_3_2 dx1w_exp_3_2 dx2w_exp_3_2
660
661 % cut the first 100 samples to remove WF transients effects
662 K12_exp_3_2(1:100,:) = [];
663 % fill struct basis
664 exps(4).fitbasis = K12_exp_3_2;
665
666
667 %%% Input on groud measured parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
668 fprintf('===== Input on-groud measured parameters - iter %s =====\n',num2str(1))
669
670 % init struct
671 groundexps = struct;
672
673 % value for S11
674 groundexps(1).pos = 3;
675 groundexps(1).value = 0;
676 groundexps(1).err = 1e-4;
677
678 % value for S1D
679 groundexps(2).pos = 4;
680 groundexps(2).value = 0;
681 groundexps(2).err = 1e-3;
682
683 % value for SDD
684 groundexps(3).pos = 6;
685 groundexps(3).value = 0;
686 groundexps(3).err = 1e-4;
687
688
689 %%% Get signals with nominal params %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
690 fprintf('===== Get signals with nominal params - iter %s =====\n',num2str(1))
691
692 % get response with nominal params
693 for kk = 1:numel(H.objs)
694 H.objs(kk).setParams(parnames,exp3_nomvalues);
695 end
696
697 s11 = fftfilt(oi1,H.objs(1,1));
698 s12 = fftfilt(oid,H.objs(1,2));
699 s21 = fftfilt(oi1,H.objs(2,1));
700 s22 = fftfilt(oid,H.objs(2,2));
701
702 % get signals for exp 3.1
703 ns1_exp_3_1 = s11;
704 ns1_exp_3_1.setName;
705 nsd_exp_3_1 = s21;
706 nsd_exp_3_1.setName;
707
708 % get signals for exp 3.2
709 ns1_exp_3_2 = s12;
710 ns1_exp_3_2.setName;
711 nsd_exp_3_2 = s22;
712 nsd_exp_3_2.setName;
713
714 % subtract nominal response from true signals
715 do1_exp_3_1 = o1_exp_3_1 - ns1_exp_3_1;
716 dod_exp_3_1 = od_exp_3_1 - nsd_exp_3_1;
717
718 do1_exp_3_2 = o1_exp_3_2 - ns1_exp_3_2;
719 dod_exp_3_2 = od_exp_3_2 - nsd_exp_3_2;
720
721 % do whitening
722 o1w_exp_3_1 = filter(do1_exp_3_1,wf11,plcf) + filter(dod_exp_3_1,wf12,plcf);
723 odw_exp_3_1 = filter(do1_exp_3_1,wf21,plcf) + filter(dod_exp_3_1,wf22,plcf);
724
725 o1w_exp_3_2 = filter(do1_exp_3_2,wf11,plcf) + filter(dod_exp_3_2,wf12,plcf);
726 odw_exp_3_2 = filter(do1_exp_3_2,wf21,plcf) + filter(dod_exp_3_2,wf22,plcf);
727
728
729 %%% Build fit vectors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
730
731 o1w_exp_3_1 = o1w_exp_3_1.y;
732 % cut the first 100 samples to remove WF transients effects
733 o1w_exp_3_1(1:100,:) = [];
734 exps(1).fitdata = o1w_exp_3_1;
735
736 odw_exp_3_1 = odw_exp_3_1.y;
737 % cut the first 100 samples to remove WF transients effects
738 odw_exp_3_1(1:100,:) = [];
739 exps(2).fitdata = odw_exp_3_1;
740
741 o1w_exp_3_2 = o1w_exp_3_2.y;
742 % cut the first 100 samples to remove WF transients effects
743 o1w_exp_3_2(1:100,:) = [];
744 exps(3).fitdata = o1w_exp_3_2;
745
746 odw_exp_3_2 = odw_exp_3_2.y;
747 % cut the first 100 samples to remove WF transients effects
748 odw_exp_3_2(1:100,:) = [];
749 exps(4).fitdata = odw_exp_3_2;
750
751
752 %%% do fit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
753 fprintf('===== Do fit - iter %s =====\n',num2str(1))
754 % [a,Ca,eCa,Corra,eCorra,Vu,bu,Cbu,eCbu,mse] = mdc3_exp1_linfit_v2(exps,groundexps);
755 [a,Ca,Corra,Vu,bu,Cbu,Fbu,mse] = utils.math.linfitsvd(exps,groundexps);
756
757 % store results
758 mdc3_exp3_loop_results(1).a = a;
759 mdc3_exp3_loop_results(1).Ca = Ca;
760 % mdc3_exp3_loop_results(1).eCa = eCa;
761 mdc3_exp3_loop_results(1).Corra = Corra;
762 % mdc3_exp3_loop_results(1).eCorra = eCorra;
763 mdc3_exp3_loop_results(1).Vu = Vu;
764 mdc3_exp3_loop_results(1).bu = bu;
765 mdc3_exp3_loop_results(1).Cbu = Cbu;
766 % mdc3_exp3_loop_results(1).eCbu = eCbu;
767 mdc3_exp3_loop_results(1).mse = mse;
768
769 % update nominal values with fit result
770 for kk=1:numel(usedparams)
771 for dd=1:numel(parnames)
772 if strcmp(usedparams{kk},parnames{dd})
773 exp3_nomvalues{dd} = exp3_nomvalues{dd} + a(kk);
774 end
775 end
776 end
777
778 % store parameter estimation
779 mdc3_exp3_loop_results(1).params = exp3_nomvalues;
780
781 % end
782
783
784 % %% save results
785 %
786 % % get date string
787 % str = date;
788 % % write filename
789 % filenm = sprintf('mdc3_exp3_loop_results_%s.mat',str);
790 % % save
791 % save(['C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\MDC3_Exp3\' filenm], 'mdc3_exp3_loop_results')
792 %
793 %% MSE progression
794
795 mseprog = zeros(N,1);
796 for ii=1:N
797 mseprog(ii) = mdc3_exp3_loop_results(ii).mse;
798 end
799
800 figure
801 plot(mseprog,'*-')
802 xlabel('Fit Step')
803 ylabel('Meam Square Error')
804 %
805 % %% Get params
806 %
807 % fit_vals = zeros(numel(usedparams),1);
808 % true_vals = zeros(numel(usedparams),1);
809 % pars = mdc3_exp3_loop_results(N).params;
810 %
811 %
812 % for ii=1:numel(usedparams)
813 % for jj=1:numel(parnames)
814 % if strcmp(usedparams{ii},parnames{jj})
815 % fit_vals(ii) = pars{jj};
816 % true_vals(ii) = exp3_truevalues{jj};
817 % end
818 % end
819 % end
820 %
821 % %% Testing
822 %
823 % % input true values
824 % dH = true_vals(1);
825 % dsH = true_vals(2);
826 % dS11 = true_vals(3);
827 % dS1D = true_vals(4);
828 % dSD1 = true_vals(5);
829 % dSDD = true_vals(6);
830 % dh1 = true_vals(7);
831 % dsh1 = true_vals(8);
832 % dh2 = true_vals(9);
833 % dsh2 = true_vals(10);
834 % dx1 = true_vals(11);
835 % dx2 = true_vals(12);
836 %
837 %
838 % % load nominal and true values
839 % load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\exp3_2_10perc_nomvalues.mat
840 % load C:\Users\Luigi\ltp_data_analysis\MDCs\MDC3\lf_analysis\Models\exp3_2_10perc_truevalues.mat
841 %
842 %
843 % %%% get response with true params
844 % for ii = 1:numel(H.objs)
845 % H.objs(ii).setParams(parnames,exp3_truevalues);
846 % end
847 %
848 % s11 = fftfilt(oi1,H.objs(1,1));
849 % s12 = fftfilt(oid,H.objs(1,2));
850 % s21 = fftfilt(oi1,H.objs(2,1));
851 % s22 = fftfilt(oid,H.objs(2,2));
852 %
853 % % get signals for exp 3.1
854 % s1_exp_3_1 = s11;
855 % s1_exp_3_1.setName;
856 % sd_exp_3_1 = s21;
857 % sd_exp_3_1.setName;
858 %
859 % % get signals for exp 3.2
860 % s1_exp_3_2 = s12;
861 % s1_exp_3_2.setName;
862 % sd_exp_3_2 = s22;
863 % sd_exp_3_2.setName;
864 %
865 % %%% get response with nominal params
866 % for kk = 1:numel(H.objs)
867 % H.objs(kk).setParams(parnames,exp3_nomvalues);
868 % end
869 %
870 % s11 = fftfilt(oi1,H.objs(1,1));
871 % s12 = fftfilt(oid,H.objs(1,2));
872 % s21 = fftfilt(oi1,H.objs(2,1));
873 % s22 = fftfilt(oid,H.objs(2,2));
874 %
875 % % get signals for exp 3.1
876 % ns1_exp_3_1 = s11;
877 % ns1_exp_3_1.setName;
878 % nsd_exp_3_1 = s21;
879 % nsd_exp_3_1.setName;
880 %
881 % % get signals for exp 3.2
882 % ns1_exp_3_2 = s12;
883 % ns1_exp_3_2.setName;
884 % nsd_exp_3_2 = s22;
885 % nsd_exp_3_2.setName;
886 %
887 % % subtract template from true signals
888 % ds1_exp_3_1 = s1_exp_3_1 - ns1_exp_3_1;
889 % dsd_exp_3_1 = sd_exp_3_1 - nsd_exp_3_1;
890 %
891 % ds1_exp_3_2 = s1_exp_3_2 - ns1_exp_3_2;
892 % dsd_exp_3_2 = sd_exp_3_2 - nsd_exp_3_2;
893 %
894 % %%% Get fit basis
895 %
896 % % set nominal values
897 % for jj = 1:numel(H.objs)
898 % T_dH.objs(jj).setParams(parnames,exp3_nomvalues);
899 % T_dsH.objs(jj).setParams(parnames,exp3_nomvalues);
900 % T_dS11.objs(jj).setParams(parnames,exp3_nomvalues);
901 % T_dS1D.objs(jj).setParams(parnames,exp3_nomvalues);
902 % T_dSD1.objs(jj).setParams(parnames,exp3_nomvalues);
903 % T_dSDD.objs(jj).setParams(parnames,exp3_nomvalues);
904 % T_dh1.objs(jj).setParams(parnames,exp3_nomvalues);
905 % T_dsh1.objs(jj).setParams(parnames,exp3_nomvalues);
906 % T_dh2.objs(jj).setParams(parnames,exp3_nomvalues);
907 % T_dsh2.objs(jj).setParams(parnames,exp3_nomvalues);
908 % T_dx1.objs(jj).setParams(parnames,exp3_nomvalues);
909 % T_dx2.objs(jj).setParams(parnames,exp3_nomvalues);
910 % end
911 %
912 % % get response for dH
913 % ds11 = fftfilt(oi1,T_dH.objs(1,1));
914 % ds12 = fftfilt(oid,T_dH.objs(1,2));
915 % ds21 = fftfilt(oi1,T_dH.objs(2,1));
916 % ds22 = fftfilt(oid,T_dH.objs(2,2));
917 %
918 % dH_1_exp_3_1 = ds11;
919 % dH_1_exp_3_1.setName;
920 % dH_12_exp_3_1 = ds21;
921 % dH_12_exp_3_1.setName;
922 % dH_1_exp_3_2 = ds12;
923 % dH_1_exp_3_2.setName;
924 % dH_12_exp_3_2 = ds22;
925 % dH_12_exp_3_2.setName;
926 %
927 % % get response for dsH
928 % ds11 = fftfilt(oi1,T_dsH.objs(1,1));
929 % ds12 = fftfilt(oid,T_dsH.objs(1,2));
930 % ds21 = fftfilt(oi1,T_dsH.objs(2,1));
931 % ds22 = fftfilt(oid,T_dsH.objs(2,2));
932 %
933 % dsH_1_exp_3_1 = ds11;
934 % dsH_1_exp_3_1.setName;
935 % dsH_12_exp_3_1 = ds21;
936 % dsH_12_exp_3_1.setName;
937 % dsH_1_exp_3_2 = ds12;
938 % dsH_1_exp_3_2.setName;
939 % dsH_12_exp_3_2 = ds22;
940 % dsH_12_exp_3_2.setName;
941 %
942 % % get response for dS11
943 % ds11 = fftfilt(oi1,T_dS11.objs(1,1));
944 % ds12 = fftfilt(oid,T_dS11.objs(1,2));
945 % ds21 = fftfilt(oi1,T_dS11.objs(2,1));
946 % ds22 = fftfilt(oid,T_dS11.objs(2,2));
947 %
948 % dS11_1_exp_3_1 = ds11;
949 % dS11_1_exp_3_1.setName;
950 % dS11_12_exp_3_1 = ds21;
951 % dS11_12_exp_3_1.setName;
952 % dS11_1_exp_3_2 = ds12;
953 % dS11_1_exp_3_2.setName;
954 % dS11_12_exp_3_2 = ds22;
955 % dS11_12_exp_3_2.setName;
956 %
957 % % get response for dS1D
958 % ds11 = fftfilt(oi1,T_dS1D.objs(1,1));
959 % ds12 = fftfilt(oid,T_dS1D.objs(1,2));
960 % ds21 = fftfilt(oi1,T_dS1D.objs(2,1));
961 % ds22 = fftfilt(oid,T_dS1D.objs(2,2));
962 %
963 % dS1D_1_exp_3_1 = ds11;
964 % dS1D_1_exp_3_1.setName;
965 % dS1D_12_exp_3_1 = ds21;
966 % dS1D_12_exp_3_1.setName;
967 % dS1D_1_exp_3_2 = ds12;
968 % dS1D_1_exp_3_2.setName;
969 % dS1D_12_exp_3_2 = ds22;
970 % dS1D_12_exp_3_2.setName;
971 %
972 %
973 % % get response for SD1
974 % ds11 = fftfilt(oi1,T_dSD1.objs(1,1));
975 % ds12 = fftfilt(oid,T_dSD1.objs(1,2));
976 % ds21 = fftfilt(oi1,T_dSD1.objs(2,1));
977 % ds22 = fftfilt(oid,T_dSD1.objs(2,2));
978 %
979 % dSD1_1_exp_3_1 = ds11;
980 % dSD1_1_exp_3_1.setName;
981 % dSD1_12_exp_3_1 = ds21;
982 % dSD1_12_exp_3_1.setName;
983 % dSD1_1_exp_3_2 = ds12;
984 % dSD1_1_exp_3_2.setName;
985 % dSD1_12_exp_3_2 = ds22;
986 % dSD1_12_exp_3_2.setName;
987 %
988 % % get response for SDD
989 % ds11 = fftfilt(oi1,T_dSDD.objs(1,1));
990 % ds12 = fftfilt(oid,T_dSDD.objs(1,2));
991 % ds21 = fftfilt(oi1,T_dSDD.objs(2,1));
992 % ds22 = fftfilt(oid,T_dSDD.objs(2,2));
993 %
994 % dSDD_1_exp_3_1 = ds11;
995 % dSDD_1_exp_3_1.setName;
996 % dSDD_12_exp_3_1 = ds21;
997 % dSDD_12_exp_3_1.setName;
998 % dSDD_1_exp_3_2 = ds12;
999 % dSDD_1_exp_3_2.setName;
1000 % dSDD_12_exp_3_2 = ds22;
1001 % dSDD_12_exp_3_2.setName;
1002 %
1003 % % get response for dh1
1004 % ds11 = fftfilt(oi1,T_dh1.objs(1,1));
1005 % ds12 = fftfilt(oid,T_dh1.objs(1,2));
1006 % ds21 = fftfilt(oi1,T_dh1.objs(2,1));
1007 % ds22 = fftfilt(oid,T_dh1.objs(2,2));
1008 %
1009 % dh1_1_exp_3_1 = ds11;
1010 % dh1_1_exp_3_1.setName;
1011 % dh1_12_exp_3_1 = ds21;
1012 % dh1_12_exp_3_1.setName;
1013 % dh1_1_exp_3_2 = ds12;
1014 % dh1_1_exp_3_2.setName;
1015 % dh1_12_exp_3_2 = ds22;
1016 % dh1_12_exp_3_2.setName;
1017 %
1018 % % get response for dsh1
1019 % ds11 = fftfilt(oi1,T_dsh1.objs(1,1));
1020 % ds12 = fftfilt(oid,T_dsh1.objs(1,2));
1021 % ds21 = fftfilt(oi1,T_dsh1.objs(2,1));
1022 % ds22 = fftfilt(oid,T_dsh1.objs(2,2));
1023 %
1024 % dsh1_1_exp_3_1 = ds11;
1025 % dsh1_1_exp_3_1.setName;
1026 % dsh1_12_exp_3_1 = ds21;
1027 % dsh1_12_exp_3_1.setName;
1028 % dsh1_1_exp_3_2 = ds12;
1029 % dsh1_1_exp_3_2.setName;
1030 % dsh1_12_exp_3_2 = ds22;
1031 % dsh1_12_exp_3_2.setName;
1032 %
1033 %
1034 % % get response for dh2
1035 % ds11 = fftfilt(oi1,T_dh2.objs(1,1));
1036 % ds12 = fftfilt(oid,T_dh2.objs(1,2));
1037 % ds21 = fftfilt(oi1,T_dh2.objs(2,1));
1038 % ds22 = fftfilt(oid,T_dh2.objs(2,2));
1039 %
1040 % dh2_1_exp_3_1 = ds11;
1041 % dh2_1_exp_3_1.setName;
1042 % dh2_12_exp_3_1 = ds21;
1043 % dh2_12_exp_3_1.setName;
1044 % dh2_1_exp_3_2 = ds12;
1045 % dh2_1_exp_3_2.setName;
1046 % dh2_12_exp_3_2 = ds22;
1047 % dh2_12_exp_3_2.setName;
1048 %
1049 % % get response for dsh2
1050 % ds11 = fftfilt(oi1,T_dsh2.objs(1,1));
1051 % ds12 = fftfilt(oid,T_dsh2.objs(1,2));
1052 % ds21 = fftfilt(oi1,T_dsh2.objs(2,1));
1053 % ds22 = fftfilt(oid,T_dsh2.objs(2,2));
1054 %
1055 % dsh2_1_exp_3_1 = ds11;
1056 % dsh2_1_exp_3_1.setName;
1057 % dsh2_12_exp_3_1 = ds21;
1058 % dsh2_12_exp_3_1.setName;
1059 % dsh2_1_exp_3_2 = ds12;
1060 % dsh2_1_exp_3_2.setName;
1061 % dsh2_12_exp_3_2 = ds22;
1062 % dsh2_12_exp_3_2.setName;
1063 %
1064 % % get response for dx1
1065 % ds11 = fftfilt(oi1,T_dx1.objs(1,1));
1066 % ds12 = fftfilt(oid,T_dx1.objs(1,2));
1067 % ds21 = fftfilt(oi1,T_dx1.objs(2,1));
1068 % ds22 = fftfilt(oid,T_dx1.objs(2,2));
1069 %
1070 % dx1_1_exp_3_1 = ds11;
1071 % dx1_1_exp_3_1.setName;
1072 % dx1_12_exp_3_1 = ds21;
1073 % dx1_12_exp_3_1.setName;
1074 % dx1_1_exp_3_2 = ds12;
1075 % dx1_1_exp_3_2.setName;
1076 % dx1_12_exp_3_2 = ds22;
1077 % dx1_12_exp_3_2.setName;
1078 %
1079 % % get response for dx2
1080 % ds11 = fftfilt(oi1,T_dx2.objs(1,1));
1081 % ds12 = fftfilt(oid,T_dx2.objs(1,2));
1082 % ds21 = fftfilt(oi1,T_dx2.objs(2,1));
1083 % ds22 = fftfilt(oid,T_dx2.objs(2,2));
1084 %
1085 % dx2_1_exp_3_1 = ds11;
1086 % dx2_1_exp_3_1.setName;
1087 % dx2_12_exp_3_1 = ds21;
1088 % dx2_12_exp_3_1.setName;
1089 % dx2_1_exp_3_2 = ds12;
1090 % dx2_1_exp_3_2.setName;
1091 % dx2_12_exp_3_2 = ds22;
1092 % dx2_12_exp_3_2.setName;
1093 %
1094 %
1095 %
1096 % %%% Get model response
1097 % mod1_3_1 = dH_1_exp_3_1.*dH + dsH_1_exp_3_1.*dsH + dS11_1_exp_3_1.*dS11 + dS1D_1_exp_3_1.*dS1D +...
1098 % dSD1_1_exp_3_1.*dSD1 + dSDD_1_exp_3_1.*dSDD + dh1_1_exp_3_1.*dh1 + dsh1_1_exp_3_1.*dsh1 + ...
1099 % dh2_1_exp_3_1.*dh2 + dsh2_1_exp_3_1.*dsh2 + dx1_1_exp_3_1.*dx1 + dx2_1_exp_3_1.*dx2;
1100 % mod1_3_1.setName;
1101 %
1102 % mod12_3_1 = dH_12_exp_3_1.*dH + dsH_12_exp_3_1.*dsH + dS11_12_exp_3_1.*dS11 + dS1D_12_exp_3_1.*dS1D +...
1103 % dSD1_12_exp_3_1.*dSD1 + dSDD_12_exp_3_1.*dSDD + dh1_12_exp_3_1.*dh1 + dsh1_12_exp_3_1.*dsh1 + ...
1104 % dh2_12_exp_3_1.*dh2 + dsh2_12_exp_3_1.*dsh2 + dx1_12_exp_3_1.*dx1 + dx2_12_exp_3_1.*dx2;
1105 % mod12_3_1.setName;
1106 %
1107 % mod1_3_2 = dH_1_exp_3_2.*dH + dsH_1_exp_3_2.*dsH + dS11_1_exp_3_2.*dS11 + dS1D_1_exp_3_2.*dS1D +...
1108 % dSD1_1_exp_3_2.*dSD1 + dSDD_1_exp_3_2.*dSDD + dh1_1_exp_3_2.*dh1 + dsh1_1_exp_3_2.*dsh1 + ...
1109 % dh2_1_exp_3_2.*dh2 + dsh2_1_exp_3_2.*dsh2 + dx1_1_exp_3_2.*dx1 + dx2_1_exp_3_2.*dx2;
1110 % mod1_3_2.setName;
1111 %
1112 % mod12_3_2 = dH_12_exp_3_2.*dH + dsH_12_exp_3_2.*dsH + dS11_12_exp_3_2.*dS11 + dS1D_12_exp_3_2.*dS1D +...
1113 % dSD1_12_exp_3_2.*dSD1 + dSDD_12_exp_3_2.*dSDD + dh1_12_exp_3_2.*dh1 + dsh1_12_exp_3_2.*dsh1 + ...
1114 % dh2_12_exp_3_2.*dh2 + dsh2_12_exp_3_2.*dsh2 + dx1_12_exp_3_2.*dx1 + dx2_12_exp_3_2.*dx2;
1115 % mod12_3_2.setName;
1116 %
1117 %
1118 % %% plot
1119 %
1120 % i1o1lin = mod1_3_1;
1121 % i1o1lin.setName('i1->o1 lin');
1122 % i1oDlin = mod12_3_1;
1123 % i1oDlin.setName('i1->oD lin');
1124 %
1125 % iDo1lin = mod1_3_2;
1126 % iDo1lin.setName('iD->o1 lin');
1127 % iDoDlin = mod12_3_2;
1128 % iDoDlin.setName('iD->oD lin');
1129 %
1130 % i1o1nlin = s1_exp_3_1-ns1_exp_3_1-mod1_3_1;
1131 % i1o1nlin.setName('i1->o1 nlin');
1132 % i1oDnlin = sd_exp_3_1-nsd_exp_3_1-mod12_3_1;
1133 % i1oDnlin.setName('i1->oD nlin');
1134 %
1135 % iDo1nlin = s1_exp_3_2-ns1_exp_3_2-mod1_3_2;
1136 % iDo1nlin.setName('iD->o1 nlin');
1137 % iDoDnlin = sd_exp_3_2-nsd_exp_3_2-mod12_3_2;
1138 % iDoDnlin.setName('iD->oD nlin');
1139 %
1140 % iplot(i1o1lin,i1o1nlin)
1141 % iplot(i1oDlin,i1oDnlin)
1142 % iplot(iDo1lin,iDo1nlin)
1143 % iplot(iDoDlin,iDoDnlin)
1144 %
1145 % %% Get Euclidean Norm
1146 %
1147 % n1lin = norm(i1o1lin.y);
1148 % n2lin = norm(i1oDlin.y);
1149 % n3lin = norm(iDo1lin.y);
1150 % n4lin = norm(iDoDlin.y);
1151 %
1152 % n1nlin = norm(i1o1nlin.y);
1153 % n2nlin = norm(i1oDnlin.y);
1154 % n3nlin = norm(iDo1nlin.y);
1155 % n4nlin = norm(iDoDnlin.y);
1156 %
1157
1158
1159
1160
1161
1162
1163
1164