comparison m-toolbox/test/test_sweptsine.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 clear all;
2
3 %% Make some test data
4
5 amps = [1 2 3 4 5 6 7];
6 freqs = [0.005 0.05 0.1 0.2 0.3 0.4 0.5 0.7];
7 nsecs = [400 200 100 100 100 100 100 100];
8 gaps = [50 50 150 50 50 50 50 50];
9 toffs(1) = gaps(1);
10 for kk=2:numel(nsecs)
11 toffs(kk) = sum(gaps(1:kk)) + sum(nsecs(1:kk-1));
12 end
13
14 sigs = ao(plist('waveform', 'sine wave', ...
15 'nsecs', nsecs, ...
16 'fs', 10, ...
17 'A', amps, ...
18 'f', freqs, ...
19 'toff', toffs, 'yunits', 'V'))
20
21 sigs.zeropad(plist('N', 1000))
22 sigs = sigs + ao(plist('tsfcn', '10*randn(size(t))', 'fs', 10, 'nsecs', sigs.nsecs));
23 sigs.setName;
24 % sigs.iplot
25
26 %% filter the data
27 pzm = pzmodel(1, {[0.05 2]}, {[0.5 2]});
28 pzm.setIunits('V');
29 pzm.setOunits('m');
30 f = miir(pzm, plist('fs', 10));
31 r = f.resp(plist('f', logspace(-3,log10(5), 1000)));
32 % iplot(r)
33
34 out = filter(sigs, f) + ...
35 ao(plist('tsfcn', '1*randn(size(t))', 'fs', 10, 'nsecs', sigs.nsecs));
36 out.setName;
37 iplot(sigs, out)
38
39 %% Create the start times
40 startTimes = time;
41 t0 = sigs.t0;
42 for ii=1:numel(toffs)
43 startTimes(ii) = t0 + toffs(ii);
44 end
45 startTimes
46
47 %% Swept-sine measurement
48
49
50 pl = plist('start times', startTimes, ...
51 'durations', nsecs, ...
52 'input', sigs, 'frequencies', freqs);
53
54 t1 = quasiSweptSine(out, pl)
55
56
57 t1.dy ./ abs(t1.y)
58
59 %% Plot abs/phase
60
61 ppl = plist('markers', {'', 'o'}, 'linestyles', {'', 'none'},...
62 'yranges', {[1e-3,1e2], [-180,180]})
63 iplot(r, t1, ppl)
64
65 %% Plot real/imag
66
67 ppl = plist('markers', {'', 'o'}, 'linestyles', {'', 'none'},...
68 'YERRL', {[], t1.y-t1.dy}, ...
69 'COMPLEXPLOTTYPE', 'realimag', 'xscales', {'all', 'log'}, ...
70 'yscales', {'lin', 'lin'})
71 iplot(r, t1, ppl)
72
73 %% Plot abs/rad
74
75 ppl = plist('markers', {'', 'o'}, 'linestyles', {'', 'none'},...
76 'YERRL', {[], t1.y-t1.dy}, ...
77 'COMPLEXPLOTTYPE', 'absrad', 'xscales', {'all', 'log'}, ...
78 'yscales', {'lin', 'lin'})
79 iplot(r, t1, ppl)
80
81 %% Measure tf with ltfe
82
83 Te = ltfe(sigs, out);
84
85 iplot(Te)
86
87 Te = tfe(sigs, out, plist('navs', 100));
88
89 iplot(Te)
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106