comparison m-toolbox/test/test_ao_cpsd.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 ao/cpsd functionality.
2 %
3 % M Hewitson 08-05-08
4 %
5 % $Id: test_ao_cpsd.m,v 1.6 2009/03/26 09:04:05 miquel Exp $
6 %
7 function test_ao_cpsd()
8
9 % Make test AOs
10
11 nsecs = 10;
12 fs = 1000;
13
14 pl = plist();
15 pl.append('nsecs', nsecs);
16 pl.append('fs', fs);
17 pl.append('tsfcn', 'sin(2*pi*7.433*t) + randn(size(t))');
18
19 a1 = ao(pl);
20 a2 = ao(pl);
21
22 % Filter one time-series
23
24 % Make a filter
25 pl = plist('type', 'bandpass', 'fs', 1000, 'order', 3, 'fc', [50 250]);
26 f2 = miir(pl);
27
28 % filter the input data
29 [a3, f2] = filter(a1,plist('filter', f2));
30
31 % make some cross-power
32 a4 = 10.*a3+a2;
33
34 % Make CPSD from a6 to a7
35 Nfft = 1000;
36 win = specwin('Hanning', Nfft);
37 pl = plist('Nfft', Nfft, 'Win', win, 'order', 2);
38 a8 = cpsd(a1, a4, pl);
39
40 % Use matlab
41 [pxy, f] = cpsd(a1.data.y, a4.data.y, win.win, Nfft/2, Nfft, a1.data.fs);
42 a9 = ao(fsdata(f.', pxy.'));
43
44 % Plot
45 iplot(a8, a9, plist('LineStyles', {'', '--'}))
46 iplot(a8 ./ a9)
47
48 % Test cpsd(a1,a1) = psd(a1)
49 a10 = cpsd(a1, a1, pl);
50 a11 = psd(a1, pl);
51
52 iplot(a10,a11)
53
54 end