0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % TEST matrix/MultiChannelNoise
|
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 % HISTORY: 23-04-2009 L Ferraioli
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % Creation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %% VERSION
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 '$Id: test_matrix_fromCSD.m,v 1.3 2009/04/23 16:03:55 luigi Exp $';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %% Loading spectra
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 fs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 f = [logspace(-6,log10(fs/2),2000)]';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % currPath = cd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % cd MDC1 % assuming to start from ..\ltpda\software\m-toolbox\test
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % [TF,CSD] = mdc1_tf_models(plist('f',f,'fs',fs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % cd(currPath)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % get noise psd shapes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % parameters names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 parnames = {'DH','S11','S1D','SD1','SDD','Dh1','Dh2','w1','w2',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 'TH','Th1','Th2'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % nominal params values
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 parvalues = {1,1,0,-1e-4,1,1,1,-1.3e-6,-2.0e-6,0.35,0.25,0.28};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % Noise model
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 Ns = matrix(plist('built-in','mdc3_ifo2ifo_noise'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % evalueat model
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 [rw,cl]=size(Ns.objs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 for ii=1:rw
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 for jj=1:cl
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 Ns.objs(ii,jj).setParams(parnames,parvalues);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 Ns.objs(ii,jj).setXvals(f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 CSD(ii,jj)=eval(Ns.objs(ii,jj));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 if ii==jj
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 CSD(ii,jj)= abs(CSD(ii,jj));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 %% Plot
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 plpl = plist('Linecolors', {'k', 'r', 'b'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 'LineStyles', {'-', '--', ':'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 'LineWidths', {3, 3, 3},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 'Legends', {'S_{o_1 o_1}', 'S_{o_1 o_\Delta}', 'S_{o_\Delta o_\Delta}'});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % iplot(CSD(1,1),CSD(1,2),CSD(2,1),CSD(2,2))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 iplot(CSD(1,1),CSD(1,2),CSD(2,2),plpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 % 2 Dimensional Noisegen Filter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 %% 2 dim noisegen filter in z domain - symbolic precision All pass
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 % plist for noise generation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 plns = plist(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 'csd', CSD, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 'targetobj', 'miir', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 'fs', fs, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 'MaxIter', 70, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 'PoleType', 3, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 'MinOrder', 25, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 'MaxOrder', 55, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 'Weights', 2, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 'Plot', false,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 'MSEVARTOL', 1e-1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 'FITTOL', 1e-4,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 'UseSym', 'on',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 'iunits', 'm',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 'ounits', 'm');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 na = matrix(plns);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 %% Check response of CSD
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 na11 = resp(na.objs(1,1).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 na12 = resp(na.objs(1,2).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 na21 = resp(na.objs(2,1).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 na22 = resp(na.objs(2,2).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 mna = matrix([na11 na12;na21 na22]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 ECSD = mna*conj(transpose(mna));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 for kk = 1:numel(CSD)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 CSD(kk).setYunits((unit('m')^2)*(unit('Hz')^-1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 CSD(kk).setXunits(unit('Hz'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 ECSD.objs(kk).setYunits((unit('m')^2)*(unit('Hz')^-1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 ECSD.objs(kk).setXunits(unit('Hz'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 % calculate cross-coherence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 COH = CSD(1,2)./sqrt(CSD(1,1).*CSD(2,2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 COH.simplifyYunits;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 RCOH = real(COH);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 ICOH = imag(COH);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 ECOH = ECSD.objs(1,2)./sqrt(ECSD.objs(1,1).*ECSD.objs(2,2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 ECOH.simplifyYunits;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 RECOH = real(ECOH);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 IECOH = imag(ECOH);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 % set plist for plotting
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 plpl = plist('Linecolors', {'k', 'r', 'b'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 'LineStyles', {'-', '--', ':'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 'LineWidths', {3, 3, 3},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 'Legends', {'Model', 'Fit', 'Residuals'});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 iplot(CSD(1,1),ECSD.objs(1,1),abs(CSD(1,1)-ECSD.objs(1,1)),plpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 iplot(CSD(2,2),ECSD.objs(2,2),abs(CSD(2,2)-ECSD.objs(2,2)),plpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 plpl = plist('Linecolors', {'k', 'r', 'b'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 'LineStyles', {'-', '--', ':'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 'LineWidths', {3, 3, 3},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 'Legends', {'Model', 'Fit', 'Residuals'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 'Yscales', {'All', 'lin'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 'Ylabels', {'All', 'Re(coh)'});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 iplot(RCOH,RECOH,abs(RCOH-RECOH),plpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 plpl = plist('Linecolors', {'k', 'r', 'b'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 'LineStyles', {'-', '--', ':'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 'LineWidths', {3, 3, 3},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 'Legends', {'Model', 'Fit', 'Residuals'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 'Yscales', {'All', 'lin'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 'Ylabels', {'All', 'Im(coh)'});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 iplot(ICOH,IECOH,abs(ICOH-IECOH),plpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 %% Check response of Filters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % na11 = resp(na.objs(1,1).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 % na12 = resp(na.objs(1,2).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 % na21 = resp(na.objs(2,1).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 % na22 = resp(na.objs(2,2).filters,plist('f',f,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 % iplot(TF(1,1),na11,abs(TF(1,1) - na11))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 % iplot(TF(1,2),na12,abs(TF(1,2) - na12))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 % iplot(TF(2,1),na21,abs(TF(2,1) - na21))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 % iplot(TF(2,2),na22,abs(TF(2,2) - na22))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 iplot(na11,na12,na21,na22)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 % 2 Dimensional Noise Generation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 nsecs = 3e5;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 plng = plist(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 'model', na,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 'Nsecs', nsecs,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 'fs', fs,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 'yunits', 'm');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 no = matrix(plng);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 %% Check psd
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 no1 = no.objs(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 no2 = no.objs(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 no1xx = no1.psd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 no2xx = no2.psd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 iplot(no1xx,csd11,no2xx,csd22)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 %% Check cross-coherence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 no1 = no.objs(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 no2 = no.objs(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 nfft = 6e4;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 no12xx = cpsd(no1,no2,plist('nfft',nfft));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 no1xx = no1.psd(plist('nfft',nfft));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 no2xx = no2.psd(plist('nfft',nfft));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 ecoh = no12xx./(sqrt(no1xx.*no2xx));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 recoh = real(ecoh);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 iecoh = imag(ecoh);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 iplot(recoh,RECOH,plist('Yscales',{'All','lin'}))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 iplot(iecoh,IECOH,plist('Yscales',{'All','lin'}))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 %% Get averaged noise spectral curves
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 N = 500;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 nsecs = 3e5;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 nfft = 6e4;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 Mnxx1 = 0; Mn2xx1 = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 Mnxx2 = 0; Mn2xx2 = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 Mnxy1 = 0; Mn2xy1 = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 Mnxy2 = 0; Mn2xy2 = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 tic
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 for ii = 1:N
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 fprintf('===== iter %s =====\n',num2str(ii))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 % noise generation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 plng = plist(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 'model', na,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 'Nsecs', nsecs,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 'fs', fs,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 'yunits', 'm');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 no = matrix(plng);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 % periodogram calculation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 no1 = no.objs(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 no2 = no.objs(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 no1xx = no1.psd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 no2xx = no2.psd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 f1 = no1xx.x;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 % running average and variance for periodogram
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 if ii == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 Mnxx1 = no1xx.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 Mnxx2 = no2xx.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 % Qxx1 = no1xx.y - Mnxx1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 Mnxx1 = Mnxx1 + (no1xx.y - Mnxx1)./ii;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 Mn2xx1 = Mn2xx1 + (no1xx.y - Mnxx1).*(no1xx.y - Mnxx1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 % Qxx2 = no2xx.y - Mnxx2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 Mnxx2 = Mnxx2 + (no2xx.y - Mnxx2)./ii;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 Mn2xx2 = Mn2xx2 + (no2xx.y - Mnxx2).*(no2xx.y - Mnxx2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 clear no1xx no2xx
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 % cross coherence calculation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 no12xx = cpsd(no1,no2,plist('nfft',nfft));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 no1xx2 = no1.psd(plist('nfft',nfft));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 no2xx2 = no2.psd(plist('nfft',nfft));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 f2 = no1xx2.x;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 ecoh = (no12xx.y)./(sqrt((no1xx2.y).*(no2xx2.y)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 recoh = real(ecoh);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 iecoh = imag(ecoh);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 clear no12xx no1xx2 no2xx2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 % running average and variance for cross coherence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 if ii == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 Mnxy1 = recoh;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 Mnxy2 = iecoh;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 % Qxy1 = recoh - Mnxy1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 Mnxy1 = Mnxy1 + (recoh - Mnxy1)./ii;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 Mn2xy1 = Mn2xy1 + (recoh - Mnxy1).*(recoh - Mnxy1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 % Qxy2 = iecoh - Mnxy2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 Mnxy2 = Mnxy2 + (iecoh - Mnxy2)./ii;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 Mn2xy2 = Mn2xy2 + (iecoh - Mnxy2).*(iecoh - Mnxy2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 toc
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 % get mean and variance for psd 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 Sxx1 = Mnxx1; % mean
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 if N == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 Svxx1 = Sxx1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 Svxx1 = (Mn2xx1/(N-1))/N; % variance
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 % get mean and variance for psd 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 Sxx2 = Mnxx2; % mean
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 if N == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 Svxx2 = Sxx2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 Svxx2 = (Mn2xx2/(N-1))/N; % variance
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 % get mean and variance for real part of cross coherence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 Sxy1 = Mnxy1; % mean
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 if N == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 Svxy1 = Sxy1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 Svxy1 = (Mn2xy1/(N-1))/N; % variance
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 % get mean and variance for imaginary part of cross coherence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 Sxy2 = Mnxy2; % mean
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 if N == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 Svxy2 = Sxy2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 Svxy2 = (Mn2xy2/(N-1))/N; % variance
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 % save results
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxx1.mat','Sxx1')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxx1.mat','Svxx1')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxx2.mat','Sxx2')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxx2.mat','Svxx2')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxy1.mat','Sxy1')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxy1.mat','Svxy1')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxy2.mat','Sxy2')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxy2.mat','Svxy2')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\f1.mat','f1')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 save('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\f2.mat','f2')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 save(na,'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\na.mat')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 %% Load saved data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxx1.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxx1.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxx2.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxx2.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxy1.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxy1.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxy2.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxy2.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\f1.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\f2.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 %% Plot spectra
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 p22 = loglog(f1(1:end-1),Sxx1(1:end-1) + sqrt(Svxx1(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 p23 = loglog(f1(1:end-1),Sxx1(1:end-1) - sqrt(Svxx1(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 p21 = loglog(f1(1:end-1),Sxx1(1:end-1),'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 p11 = loglog(ECSD.objs(1,1).x,ECSD.objs(1,1).y,'k','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 xlabel('Frequency [Hz]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 ylabel('amplitude [m^2 Hz^{-1}]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 legend([p11(1) p21(1) p22(1)],'Fit Model', 'Data', 'Error \pm \sigma')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 p22 = loglog(f1(1:end-1),Sxx2(1:end-1) + sqrt(Svxx2(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 p23 = loglog(f1(1:end-1),Sxx2(1:end-1) - sqrt(Svxx2(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 p21 = loglog(f1(1:end-1),Sxx2(1:end-1),'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 p11 = loglog(ECSD.objs(2,2).x,ECSD.objs(2,2).y,'k','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 xlabel('Frequency [Hz]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 ylabel('amplitude [m^2 Hz^{-1}]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 legend([p11(1) p21(1) p22(1)],'Fit Model', 'Data', 'Error \pm \sigma')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 %% Plot coherence
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 p22 = semilogx(f2,Sxy1 + sqrt(Svxy1),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 p23 = semilogx(f2,Sxy1 - sqrt(Svxy1),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 p21 = semilogx(f2,Sxy1,'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 p11 = semilogx(RECOH.x,RECOH.y,'k','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 xlabel('Frequency [Hz]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 ylabel('Re(coh) []','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 legend([p11(1) p21(1) p22(1)],'Fit Model', 'Data', 'Error \pm \sigma')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 p22 = semilogx(f2,Sxy2 + sqrt(Svxy2),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 p23 = semilogx(f2,Sxy2 - sqrt(Svxy2),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 p21 = semilogx(f2,Sxy2,'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 p11 = semilogx(IECOH.x,IECOH.y,'k','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 xlabel('Frequency [Hz]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 ylabel('Im(coh) []','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 legend([p11(1) p21(1) p22(1)],'Fit Model', 'Data', 'Error \pm \sigma')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 %% Check response of CSD
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 currPath = cd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 cd MDC1 % assuming to start from ..\ltpda\software\m-toolbox\test
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 [TF,CSD] = mdc1_tf_models(plist('f',f1,'fs',fs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 cd(currPath)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 na11 = resp(na.objs(1,1).filters,plist('f',f1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 na12 = resp(na.objs(1,2).filters,plist('f',f1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 na21 = resp(na.objs(2,1).filters,plist('f',f1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 na22 = resp(na.objs(2,2).filters,plist('f',f1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 mna = matrix([na11 na12;na21 na22]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 ECSD = mna*conj(transpose(mna));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 for kk = 1:numel(CSD)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 CSD(kk).setYunits((unit('m')^2)*(unit('Hz')^-1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 CSD(kk).setXunits(unit('Hz'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 ECSD.objs(kk).setYunits((unit('m')^2)*(unit('Hz')^-1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 ECSD.objs(kk).setXunits(unit('Hz'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 plpl = plist('Linecolors', {'k', 'r', 'b'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 'LineStyles', {'-', '--', ':'},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 'LineWidths', {3, 3, 3},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 'Legends', {'Model', 'Fit', 'Residuals'});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 iplot(CSD(1,1),ECSD.objs(1,1),abs(CSD(1,1)-ECSD.objs(1,1)),plpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 iplot(CSD(2,2),ECSD.objs(2,2),abs(CSD(2,2)-ECSD.objs(2,2)),plpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 %% get expected response + window
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 % we should considere that the window has a spectral response that can add
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 % some systematics inside our spectral estimations. Since the window is a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 % product in time domain with the time series, that it corresponds to a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 % convolution in frequency domain. We can ifft the frequency response of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 % the filters, multiply in time domain for the window and then come back to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 % freq domain by fft.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 na = matrix('C:\Users\Luigi\Lavori\ltp_noisegen\matlab\na.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 % filter responses
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 fs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 nsecs = 3e5;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 nfft = nsecs.*fs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 ff1 = (0:floor(nfft/2)).*fs./nfft;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 rsp11 = resp(na.objs(1,1).filters,plist('f',ff1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 rsp11 = rsp11.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 % rsp11 = [rsp11(1:end-1);flipud(conj(rsp11(2:end)))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 rsp12 = resp(na.objs(1,2).filters,plist('f',ff1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 rsp12 = rsp12.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 % rsp12 = [rsp12(1:end-1);flipud(conj(rsp12(2:end)))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 rsp21 = resp(na.objs(2,1).filters,plist('f',ff1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 rsp21 = rsp21.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 % rsp21 = [rsp21(1:end-1);flipud(conj(rsp21(2:end)))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 rsp22 = resp(na.objs(2,2).filters,plist('f',ff1,'bank','parallel'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 rsp22 = rsp22.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 % rsp22 = [rsp22(1:end-1);flipud(conj(rsp22(2:end)))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 clear na
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 % psd calc (npsd should contain nfft samples)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 npsd11 = rsp11.*conj(rsp11) + rsp12.*conj(rsp12);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 % npsd11 = [npsd11;flipud(npsd11(2:end-1))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 npsd22 = rsp21.*conj(rsp21) + rsp22.*conj(rsp22);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 % npsd22 = [npsd22;flipud(npsd22(2:end-1))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 % get window frequency response
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 % BH92 in frequency domain
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 W = BH92(2.*pi.*ff1./fs,nfft);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 W = W./max(abs(W));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 W = W.*conj(W);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 %% ifft dello spettro
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 % npsd11 = [npsd11;flipud(npsd11(2:end-1))]./2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 % npsd22 = [npsd22;flipud(npsd22(2:end-1))]./2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 % g11 = ifft(npsd11);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 % g22 = ifft(npsd22);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 W = blackmanharris(nfft);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 if size(W,2)>1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 W = W.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 W = W.^2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 W = ifftshift(W);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 WS11 = fft(W.*g11);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 WS22 = fft(W.*g22);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 WS11 = 2.*WS11(1:numel(ff1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 WS22 = 2.*WS22(1:numel(ff1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 %% get convolution
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 % WS11 = conv(W,npsd11);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 % WS11 = WS11(1:numel(ff1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 %% Plot spectra
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxx1.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxx1.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Sxx2.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 load 'C:\Users\Luigi\Lavori\ltp_noisegen\matlab\Svxx2.mat'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 p22 = loglog(ff1(1:end-1),Sxx1(1:end-1) + sqrt(Svxx1(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 p23 = loglog(ff1(1:end-1),Sxx1(1:end-1) - sqrt(Svxx1(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 p21 = loglog(ff1(1:end-1),Sxx1(1:end-1),'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 p11 = loglog(ff1(1:end),WS11(1:end),'k','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 xlabel('Frequency [Hz]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 ylabel('amplitude [m^2 Hz^{-1}]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 legend([p11(1) p21(1) p22(1)],'Fit Model', 'Data', 'Error \pm \sigma')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 p22 = loglog(ff1(1:end-1),Sxx2(1:end-1) + sqrt(Svxx2(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 p23 = loglog(ff1(1:end-1),Sxx2(1:end-1) - sqrt(Svxx2(1:end-1)),'b','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 p21 = loglog(ff1(1:end-1),Sxx2(1:end-1),'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 p11 = loglog(ff1(1:end-1),WS22(1:end-1),'k','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 xlabel('Frequency [Hz]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 ylabel('amplitude [m^2 Hz^{-1}]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 legend([p11(1) p21(1) p22(1)],'Fit Model', 'Data', 'Error \pm \sigma')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536 %% get statistics
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 Sn11 = (npsd11(14:end-1)-Sxx1(14:end-1))./npsd11(14:end-1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539 Sn11 = ao(cdata(Sn11));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 Sn22 = (npsd22(14:end-1)-Sxx2(14:end-1))./npsd22(14:end-1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 Sn22 = ao(cdata(Sn22));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543 % get equivalent normal distribution and histogram
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 hpl1 = plist('N', 50);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545 hpl2 = plist('N', 200);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547 dS11h = hist(Sn11,hpl1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 dS11h = dS11h./max(dS11h);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549 dS11n = normdist(Sn11,hpl2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 dS11n = dS11n./max(dS11n);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 dS22h = hist(Sn22,hpl1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553 dS22h = dS22h./max(dS22h);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 dS22n = normdist(Sn22,hpl2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 dS22n = dS22n./max(dS22n);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557 %% check
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 iplot(dS11h,dS11n)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560 iplot(dS22h,dS22n)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562 %% Plot results of the statistics analysis
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566 p1 = bar(dS11h.x,dS11h.y,'b');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 p2 = plot(dS11n.x,dS11n.y,'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571 xlabel('Normalized Deviation [\Deltax / x]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572 ylabel('Normalized Counts','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573 legend([p1(1) p2(1)],'Histogram', 'Equivalent Norm. Distr.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575 figure()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 p1 = bar(dS22h.x,dS22h.y,'b');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578 hold on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 p2 = plot(dS22n.x,dS22n.y,'r','LineWidth',3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582 xlabel('Normalized Deviation [\Deltax / x]','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 ylabel('Normalized Counts','fontsize',18)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584 legend([p1(1) p2(1)],'Histogram', 'Equivalent Norm. Distr.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 m1 = mean(Sn11.y);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590 m2 = mean(Sn22.y);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 s1 = std(Sn11.y);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 s2 = std(Sn22.y);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 nfft = 1e2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601 fs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602 frq = linspace(0,pi,10000);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603 % D=DirichletKernel(frq,nfft);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 % D=D./max(D);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605 % figure;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606 % plot(frq,20.*log10(D))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607 % grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 W=BH92(frq,nfft);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609 % W=W./max(W);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 figure;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
611 plot(frq./pi,20.*log10(W))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
612 grid on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
613
|