Mercurial > hg > ltpda
comparison m-toolbox/test/test_ao_whiten2D.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 % A test script for ao/whiten2D | |
2 % | |
3 % L. Ferraioli 18-11-08 | |
4 % | |
5 % $Id: test_ao_whiten2D.m,v 1.6 2009/04/20 14:31:14 luigi Exp $ | |
6 % | |
7 | |
8 %% | |
9 | |
10 clear all | |
11 | |
12 %% CSD Noise models | |
13 | |
14 % Mdc2 noise model | |
15 % mod = ltpnoise(); | |
16 | |
17 load mpsd.mat % load mpsd.mat first column is f then csd11, csd12 and csd22 | |
18 | |
19 f = mpsd(:,1); % frequency vector | |
20 csd11 = mpsd(:,2); | |
21 csd12 = mpsd(:,3); | |
22 csd22 = mpsd(:,4); | |
23 fs = 10; % sampling frequency | |
24 | |
25 % Building AOs | |
26 ltp_csd11 = ao(fsdata(f,csd11,fs)); | |
27 ltp_csd12 = ao(fsdata(f,csd12,fs)); | |
28 ltp_csd21 = ao(fsdata(f,conj(csd12),fs)); | |
29 ltp_csd22 = ao(fsdata(f,csd22,fs)); | |
30 | |
31 %% | |
32 | |
33 iplot(ltp_csd11,ltp_csd12,ltp_csd22) | |
34 | |
35 %% Colored Noise generation | |
36 | |
37 % Make white noise | |
38 | |
39 a1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 10000)); | |
40 a2 = ao(plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 10000)); | |
41 a = [a1 a2]; | |
42 | |
43 % Generation from white noise | |
44 | |
45 pl = plist(... | |
46 'csd11', ltp_csd11,... | |
47 'csd12', ltp_csd12,... | |
48 'csd21', ltp_csd21,... | |
49 'csd22', ltp_csd22,... | |
50 'MaxIter', 70, ... | |
51 'PoleType', 2, ... | |
52 'MinOrder', 20, ... | |
53 'MaxOrder', 30, ... | |
54 'Weights', 2, ... | |
55 'Plot', false,... | |
56 'MSEVARTOL', 1e-2,... | |
57 'FITTOL', 1e-3,... | |
58 'UseSym', 0,... | |
59 'Disp', false); | |
60 | |
61 ac = noisegen2D(a, pl); | |
62 | |
63 %% Checking generated noise | |
64 | |
65 acxx1 = ac(1).psd; | |
66 acxx2 = ac(2).psd; | |
67 acxx12 = ac.cpsd; | |
68 | |
69 iplot(abs(acxx1),abs(ltp_csd11)) | |
70 iplot(abs(acxx12),abs(ltp_csd12)) | |
71 iplot(abs(acxx2),abs(ltp_csd22)) | |
72 | |
73 %% Noise whitening | |
74 | |
75 pl = plist(... | |
76 'csd11', ltp_csd11, ... | |
77 'csd12', ltp_csd12, ... | |
78 'csd21', ltp_csd21, ... | |
79 'csd22', ltp_csd22, ... | |
80 'MaxIter', 75, ... | |
81 'PoleType', 3, ... | |
82 'MinOrder', 20, ... | |
83 'MaxOrder', 40, ... | |
84 'Weights', 2, ... | |
85 'Plot', false,... | |
86 'MSEVARTOL', 1e-2,... | |
87 'FITTOL', 1e-3,... | |
88 'UseSym', 0,... | |
89 'Disp', false); | |
90 | |
91 aw = whiten2D(ac, pl); | |
92 | |
93 %% Checking whitened noise | |
94 | |
95 awxx1 = aw(1).psd; | |
96 awxx2 = aw(2).psd; | |
97 | |
98 %% | |
99 iplot(awxx1,awxx2) | |
100 | |
101 %% Checking | |
102 | |
103 aw1 = aw(1); | |
104 aw2 = aw(2); | |
105 awxx1 = awxx(1,1); | |
106 awxx2 = awxx(2,2); | |
107 | |
108 mw1 = aw1.mean; % 0 expected | |
109 vw1 = aw1.var; % 1 expected | |
110 | |
111 mw2 = aw2.mean; % 0 expected | |
112 vw2 = aw2.var; % 1 expected | |
113 | |
114 mwxx1 = awxx1.mean; % 0.2 expected | |
115 vwxx1 = awxx1.var; | |
116 | |
117 mwxx2 = awxx2.mean; % 0.2 expected | |
118 vwxx2 = awxx2.var; | |
119 | |
120 % correlation coefficients | |
121 % diagonal terms are aw1 and aw2 variances | |
122 % cross terms are data series covariances, a value close to 0 means no | |
123 % correlation between the data series | |
124 crc = corrcoef([aw1.data.y.' aw2.data.y.']); | |
125 | |
126 | |
127 % END |