comparison m-toolbox/test/test_miir_redesign.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 % When the filter command is given a standard filter designed for a
2 % different sample rate than the input data, we should redesign the filter
3 % on the fly. This can be done since the filter object contains the plist
4 % that was used to design it.
5 %
6 % M Hewitson 04-04-07
7 %
8 % $Id: test_miir_redesign.m,v 1.9 2009/07/21 05:16:29 hewitson Exp $
9 function test_miir_redesign()
10
11
12 % Make a filter
13 pl = plist('type', 'bandpass', 'fs', 1000, 'fc', [50 100], 'order', 3);
14 f = miir(pl)
15
16
17 % Make test AOs
18 nsecs = 10;
19 fs = 5000;
20 pl = plist('nsecs', nsecs, 'fs', fs, 'tsfcn', 'sin(2*pi*7.433*t) + randn(size(t))');
21
22 a1 = ao(pl);
23
24 % Filter the input data
25 [a2, f] = filter(a1,plist('filter', f));
26
27 % Plot time-series
28 iplot(a1, a2)
29
30 % Make PSDs of input and output
31 nfft = 16384;
32 w = specwin('Hanning', nfft);
33 pl = plist('Win', w, 'Nfft', nfft);
34
35 a3 = psd(a1, pl);
36 a4 = psd(a2, pl);
37
38 % Plot PSDs
39 iplot([a3 a4])
40
41 end
42 % END
43