Mercurial > hg > ltpda
comparison m-toolbox/test/utils/test_eigcsd.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 utils.math.eigcsd | |
2 % | |
3 % L. Ferraioli 18-11-08 | |
4 % | |
5 % $Id: test_eigcsd.m,v 1.2 2009/06/10 16:12:06 luigi Exp $ | |
6 % | |
7 | |
8 %% | |
9 | |
10 clear all | |
11 | |
12 %% CSD Noise models and TF | |
13 | |
14 [CSD,TF] = get_2D_test_obj_tf_psd(); | |
15 | |
16 % get noise coherence | |
17 % coh = CSD(1,2)./sqrt(abs(CSD(1,1).*CSD(2,2))); | |
18 % rcoh = real(coh); | |
19 % rcoh.setName; | |
20 % icoh = imag(coh); | |
21 % icoh.setName; | |
22 | |
23 %% Get Noisegen TFs numerically | |
24 | |
25 [tf11,tf12,tf21,tf22] = utils.math.eigcsd(CSD(1,1).y,CSD(1,2).y,CSD(2,1).y,CSD(2,2).y,'USESYM',0,'DIG',50,'OTP','TF'); | |
26 | |
27 % Build AOs | |
28 h11 = ao(plist('xvals', TF(1,1).x, 'yvals', tf11, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
29 h11.setName; | |
30 h12 = ao(plist('xvals', TF(1,1).x, 'yvals', tf12, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
31 h12.setName; | |
32 h21 = ao(plist('xvals', TF(1,1).x, 'yvals', tf21, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
33 h21.setName; | |
34 h22 = ao(plist('xvals', TF(1,1).x, 'yvals', tf22, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
35 h22.setName; | |
36 | |
37 | |
38 %% Checking generated TFs | |
39 | |
40 iplot(abs(abs(TF(1,1))-abs(h11))) | |
41 iplot(abs(abs(TF(1,2))-abs(h12))) | |
42 iplot(abs(abs(TF(2,1))-abs(h21))) | |
43 iplot(abs(abs(TF(2,2))-abs(h22))) | |
44 | |
45 %% Calculate psd | |
46 | |
47 xx11 = h11.*conj(h11)+h12.*conj(h12); | |
48 xx12 = h11.*conj(h21)+h12.*conj(h22); | |
49 xx22 = h22.*conj(h22)+h21.*conj(h21); | |
50 xx21 = conj(xx12); | |
51 xx11.setName; | |
52 xx12.setName; | |
53 xx21.setName; | |
54 xx22.setName; | |
55 | |
56 %% Compare | |
57 | |
58 iplot(CSD(1,1),xx11) | |
59 iplot(CSD(1,2),xx12) | |
60 iplot(CSD(2,1),xx21) | |
61 iplot(CSD(2,2),xx22) | |
62 | |
63 %% Get Noisegen TFs symbolically | |
64 | |
65 [tf11,tf12,tf21,tf22] = utils.math.eigcsd(CSD(1,1).y,CSD(1,2).y,CSD(2,1).y,CSD(2,2).y,'USESYM',1,'DIG',50,'OTP','TF'); | |
66 | |
67 % Build AOs | |
68 h11 = ao(plist('xvals', TF(1,1).x, 'yvals', tf11, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
69 h11.setName; | |
70 h12 = ao(plist('xvals', TF(1,1).x, 'yvals', tf12, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
71 h12.setName; | |
72 h21 = ao(plist('xvals', TF(1,1).x, 'yvals', tf21, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
73 h21.setName; | |
74 h22 = ao(plist('xvals', TF(1,1).x, 'yvals', tf22, 'fs', TF(1,1).fs, 'dtype', 'fsdata')); | |
75 h22.setName; | |
76 | |
77 | |
78 %% Checking generated TFs | |
79 | |
80 iplot(abs(abs(TF(1,1))-abs(h11))) | |
81 iplot(abs(abs(TF(1,2))-abs(h12))) | |
82 iplot(abs(abs(TF(2,1))-abs(h21))) | |
83 iplot(abs(abs(TF(2,2))-abs(h22))) | |
84 | |
85 %% Calculate psd | |
86 | |
87 xx11 = h11.*conj(h11)+h12.*conj(h12); | |
88 xx12 = h11.*conj(h21)+h12.*conj(h22); | |
89 xx22 = h22.*conj(h22)+h21.*conj(h21); | |
90 xx21 = conj(xx12); | |
91 xx11.setName; | |
92 xx12.setName; | |
93 xx21.setName; | |
94 xx22.setName; | |
95 | |
96 %% Compare | |
97 | |
98 iplot(CSD(1,1),xx11) | |
99 iplot(CSD(1,2),xx12) | |
100 iplot(CSD(2,1),xx21) | |
101 iplot(CSD(2,2),xx22) | |
102 |