Mercurial > hg > ltpda
comparison m-toolbox/test/test_ao_smoother.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_SMOOTHER a test function the AO method smoother. | |
2 % | |
3 % M Hewitson 02-03-08 | |
4 % | |
5 % $Id: test_ao_smoother.m,v 1.8 2009/02/02 15:20:38 hewitson Exp $ | |
6 % | |
7 function test_ao_smoother | |
8 | |
9 | |
10 % ------------- Frequency data smoothing --------------------------------- | |
11 | |
12 | |
13 % Make some test data | |
14 | |
15 nsecs = 5000; | |
16 fs = 10; | |
17 | |
18 p1 = pz(0.01, 1); | |
19 z1 = pz(0.2); | |
20 gain =1; | |
21 | |
22 pzm = pzmodel(gain, p1, z1); | |
23 % calling the noisegenerator | |
24 a1 = fngen(pzm, plist('Nsecs', nsecs)); | |
25 a1.setYunits('V'); | |
26 a1.setXunits('s'); | |
27 a1.setName('noise'); | |
28 a2 = ao(plist('tsfcn', '0.003.*sin(2*pi*0.65*t) + 0.001.*sin(2*pi*3*t)', 'fs', a1.data.fs, 'nsecs', nsecs)); | |
29 a2.setName('signal'); | |
30 a3 = a1 + a2; | |
31 | |
32 % parameter list for lpsd | |
33 pl = plist(... | |
34 'Kdes', 100, ... | |
35 'Kmin', 2, ... | |
36 'Jdes', 500, ... | |
37 'Win', specwin('Kaiser', 10, 150), ... | |
38 'Order', 1); | |
39 | |
40 % Make spectrum | |
41 a3xx = psd(a3, plist('Nfft', 1000*fs)); | |
42 | |
43 | |
44 % Median Smooth both | |
45 | |
46 pl = plist('width', 100, 'hc', 0.7, 'method', 'median'); | |
47 a3s = smoother(a3, pl); | |
48 pl = plist('width', 30, 'hc', 0.8, 'method', 'median'); | |
49 a3xxs = smoother(a3xx, pl); | |
50 | |
51 % Plot | |
52 pl = plist('Legends', {'', 'median'}); | |
53 iplot(a3, a3s, pl) | |
54 iplot(a3xx, a3xxs, pl) | |
55 | |
56 % Mean smooth | |
57 | |
58 | |
59 pl = plist('width', 100, 'hc', 0.7, 'method', 'mean'); | |
60 a3s = smoother(a3, pl); | |
61 pl = plist('width', 20, 'hc', 0.8, 'method', 'mean'); | |
62 a3xxs = smoother(a3xx, pl); | |
63 | |
64 % Plot | |
65 pl = plist('Legends', {'', 'mean'}); | |
66 iplot(a3, a3s, pl) | |
67 iplot(a3xx, a3xxs, pl) | |
68 | |
69 % Max smooth | |
70 | |
71 pl = plist('width', 1000, 'hc', 0.7, 'method', 'max'); | |
72 a3s = smoother(a3, pl); | |
73 pl = plist('width', 20, 'hc', 0.8, 'method', 'max'); | |
74 a3xxs = smoother(a3xx, pl); | |
75 | |
76 % Plot | |
77 pl = plist('Legends', {'', 'max'}); | |
78 iplot(a3, a3s, pl) | |
79 iplot(a3xx, a3xxs, pl) | |
80 | |
81 % Min smooth | |
82 | |
83 pl = plist('width', 1000, 'hc', 0.7, 'method', 'min'); | |
84 a3s = smoother(a3, pl); | |
85 pl = plist('width', 20, 'hc', 0.8, 'method', 'min'); | |
86 a3xxs = smoother(a3xx, pl); | |
87 | |
88 % Plot | |
89 pl = plist('Legends', {'', 'min'}); | |
90 iplot(a3, a3s, pl) | |
91 iplot(a3xx, a3xxs, pl) | |
92 | |
93 % Mode smooth | |
94 | |
95 pl = plist('width', 1000, 'hc', 0.7, 'method', 'mode'); | |
96 a3s = smoother(a3, pl); | |
97 pl = plist('width', 20, 'hc', 0.8, 'method', 'mode'); | |
98 a3xxs = smoother(a3xx, pl); | |
99 | |
100 % Plot | |
101 pl = plist('Legends', {'', 'mode'}); | |
102 iplot(a3, a3s, pl) | |
103 iplot(a3xx, a3xxs, pl) | |
104 | |
105 | |
106 end |