Mercurial > hg > ltpda
comparison m-toolbox/test/test_matrix_linfitsvd.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 for matrix/linfitsvd | |
2 % | |
3 % 17-11-2009 L Ferraioli | |
4 % CREATION | |
5 % | |
6 % | |
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
8 % $Id: test_matrix_linfitsvd.m,v 1.3 2010/04/25 21:27:57 mauro Exp $ | |
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
10 | |
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 %% Definitions | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 pl_retrieve = plist('hostname', 'btlab.science.unitn.it', 'database', 'algo_testing'); | |
16 | |
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
18 %%%%% Loading data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
20 %% Loading parameters cells | |
21 | |
22 fprintf('===== loading data... =====\n') | |
23 | |
24 % define parameters names and values | |
25 parnames = { 'S11', 'S1D', 'SD1', 'SDD', ... | |
26 'TH', 'Th2', 'dH', ... | |
27 'dS11', 'dS1D', 'dSD1', 'dSDD', ... | |
28 'dh1', 'dh2', ... | |
29 'dsH', 'dsh1', 'dsh2', ... | |
30 'dx1', 'dx2', ... | |
31 'w0', 'w1', 'w2'}; | |
32 | |
33 exp3_nomvalues = {1 0 0 1 ... | |
34 0.35 0.28 0 ... | |
35 0 0 0 0, ... | |
36 0 0, ... | |
37 0 0 0, ... | |
38 0 0, ... | |
39 0.188 0 + 0.00114i 0 + 0.00141i ... | |
40 }; | |
41 | |
42 exp3_truevalues = {1 0 0 1 ... | |
43 0.35 0.28 0.0526103537824434 ... | |
44 0 0 -0.0001 0, ... | |
45 0.0753993274155418 0.0569786061730967, ... | |
46 0.0670701072189726 0.00576108053758739 -0.0846457231187905, ... | |
47 -0.0456546316180145 0.0395739758886965, ... | |
48 0.188 0 + 0.00114i 0 + 0.00141i ... | |
49 }; | |
50 | |
51 % set ordered used parameters | |
52 usedparams = {'dH','dsH','dS11','dS1D','dSD1','dSDD',... | |
53 'dh2','dsh2','dx1','dx2'}; | |
54 | |
55 %% get non-linear response model | |
56 % the model is non-linear in the parameter dependence | |
57 fprintf('===== Get TF Model... =====\n') | |
58 | |
59 H = matrix(plist('built-in','mdc3_ifo2ifo_v2')); | |
60 | |
61 %% load input signal | |
62 % those are the same of exp 1 | |
63 | |
64 fprintf('===== Loading input signals... =====\n') | |
65 | |
66 oi1 = ao(pl_retrieve.pset('id', 1)); | |
67 oid = ao(pl_retrieve.pset('id', 2)); | |
68 | |
69 %% load Coloring filters | |
70 | |
71 fprintf('===== loading coloring filters... =====\n') | |
72 | |
73 cf = matrix(pl_retrieve.pset('id', 26)); | |
74 cf11 = cf.getObjectAtIndex(1, 1); | |
75 cf12 = cf.getObjectAtIndex(1, 2); | |
76 cf21 = cf.getObjectAtIndex(2, 1); | |
77 cf22 = cf.getObjectAtIndex(2, 2); | |
78 | |
79 %% load Whitening filters | |
80 | |
81 fprintf('===== loading whitening filters... =====\n') | |
82 | |
83 WF = matrix(pl_retrieve.pset('id', 27)); | |
84 | |
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
86 %%%%% Generating signals %%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
88 %% Get signals output of the system | |
89 | |
90 fprintf('===== get true values... =====\n') | |
91 | |
92 mod = copy(H, true); | |
93 | |
94 % get response with true params | |
95 for ii = 1:numel(H.objs) | |
96 mod.objs(ii).setParams(parnames,exp3_truevalues); | |
97 end | |
98 | |
99 plfft = plist('Npad',[]); | |
100 | |
101 s11 = fftfilt(oi1,mod.objs(1,1),plfft); | |
102 s12 = fftfilt(oid,mod.objs(1,2),plfft); | |
103 s21 = fftfilt(oi1,mod.objs(2,1),plfft); | |
104 s22 = fftfilt(oid,mod.objs(2,2),plfft); | |
105 | |
106 % get signals for exp 3.1 | |
107 s1_exp_3_1 = s11; | |
108 s1_exp_3_1.setName; | |
109 sd_exp_3_1 = s21; | |
110 sd_exp_3_1.setName; | |
111 | |
112 % get signals for exp 3.2 | |
113 s1_exp_3_2 = s12; | |
114 s1_exp_3_2.setName; | |
115 sd_exp_3_2 = s22; | |
116 sd_exp_3_2.setName; | |
117 | |
118 | |
119 %% Adding noise to signals | |
120 | |
121 fprintf('===== adding noise to signals... =====\n') | |
122 | |
123 % get params | |
124 Nsecs = s1_exp_3_1.nsecs; | |
125 fs = s1_exp_3_1.fs; | |
126 plcf = plist('bank','parallel'); | |
127 pl_noise = plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', Nsecs); | |
128 | |
129 % starting noise generation exp1.1 | |
130 a1_exp_3_1 = ao(pl_noise); | |
131 a2_exp_3_1 = ao(pl_noise); | |
132 | |
133 % coloring noise exp 1.1 | |
134 na1_exp_3_1 = filter(a1_exp_3_1,cf11,plcf) + filter(a2_exp_3_1,cf12,plcf); | |
135 na2_exp_3_1 = filter(a1_exp_3_1,cf21,plcf) + filter(a2_exp_3_1,cf22,plcf); | |
136 | |
137 % starting noise generation exp 1.2 | |
138 a1_exp_3_2 = ao(pl_noise); | |
139 a2_exp_3_2 = ao(pl_noise); | |
140 | |
141 % coloring noise exp 1.2 | |
142 na1_exp_3_2 = filter(a1_exp_3_2,cf11,plcf) + filter(a2_exp_3_2,cf12,plcf); | |
143 na2_exp_3_2 = filter(a1_exp_3_2,cf21,plcf) + filter(a2_exp_3_2,cf22,plcf); | |
144 | |
145 % adding noise to signals | |
146 o1_exp_3_1 = s1_exp_3_1 + na1_exp_3_1; | |
147 od_exp_3_1 = sd_exp_3_1 + na2_exp_3_1; | |
148 | |
149 o1_exp_3_2 = s1_exp_3_2 + na1_exp_3_2; | |
150 od_exp_3_2 = sd_exp_3_2 + na2_exp_3_2; | |
151 | |
152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
153 %%%%% Build input for linfitsvd %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
155 %% Build input objects | |
156 | |
157 % empty ao | |
158 eao = ao(); | |
159 | |
160 %% | |
161 %%% Model %%% | |
162 % get response with nominal params | |
163 for ii = 1:numel(H.objs) | |
164 H.objs(ii).setParams(parnames,exp3_nomvalues); | |
165 end | |
166 | |
167 %%% exp_3_1 %%% | |
168 os1 = matrix(o1_exp_3_1,od_exp_3_1,plist('shape',[2 1])); | |
169 is1 = matrix(oi1,eao,plist('shape',[2 1])); | |
170 | |
171 %%% exp_3_2 %%% | |
172 os2 = matrix(o1_exp_3_2,od_exp_3_2,plist('shape',[2 1])); | |
173 is2 = matrix(eao,oid,plist('shape',[2 1])); | |
174 | |
175 %% | |
176 %%% Input signals | |
177 iS = collection(is1,is2); | |
178 | |
179 %%% Known parameters | |
180 vals = [0 0 0]; | |
181 nms = {'dS11','dS1D','dSDD'}; | |
182 errs = [1e-4 1e-3 1e-4]; | |
183 kwnpar = pest(vals, nms, errs); | |
184 | |
185 | |
186 %% do fit | |
187 | |
188 plfit = plist(... | |
189 'FitParams',usedparams,... | |
190 'Model',H,... | |
191 'Input',iS,... | |
192 'WhiteningFilter',WF,... | |
193 'Nloops',30,... | |
194 'Ncut',100,... | |
195 'KnownParams',kwnpar); | |
196 | |
197 opars = linfitsvd(os1,os2,plfit); |