Mercurial > hg > ltpda
comparison m-toolbox/test/test_ao_heterodyne.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 % Tests for ao/heterodyne | |
2 % | |
3 % $Id: test_ao_heterodyne.m,v 1.4 2010/07/08 08:49:37 mauro Exp $ | |
4 % | |
5 | |
6 %% produce input signal | |
7 | |
8 fs = 10; | |
9 nsecs = 1000; | |
10 amplitude = 1e-3; | |
11 noise = 1e-6; | |
12 fmod = 0.1; | |
13 yunits = 'V'; | |
14 | |
15 % carrier | |
16 h = ao(plist('waveform', 'sine', 'f', fmod, 'a', 1, 'fs', fs, 'nsecs', nsecs, 'yunits', yunits)); | |
17 % signal | |
18 s = ao(plist('waveform', 'sine', 'f', 5e-3, 'a', 1, 'fs', fs, 'nsecs', nsecs)); | |
19 % modulate the carrier | |
20 m = h .* s; | |
21 % add noise | |
22 n = ao(plist('waveform', 'noise', 'nsecs', nsecs, 'fs', fs, 'sigma', noise, 'yunits', yunits)); | |
23 | |
24 a1 = m + n; | |
25 | |
26 %% demodulate | |
27 b1_cos = a1.heterodyne(plist('f0', fmod, 'bw', fmod, 'quad', 'cos')); | |
28 b1_sin = a1.heterodyne(plist('f0', fmod, 'bw', fmod, 'quad', 'sin')); | |
29 | |
30 iplot(s, b1_cos, b1_sin, plist('linestyles', {'-','none','none'}, 'markers', {'none','+','+'})); | |
31 | |
32 %% demodulate without downsampling | |
33 b1_cos = a1.heterodyne(plist('f0', fmod, 'ds', false, 'bw', fmod, 'quad', 'cos')); | |
34 b1_sin = a1.heterodyne(plist('f0', fmod, 'ds', false, 'bw', fmod, 'quad', 'sin')); | |
35 | |
36 iplot(s, b1_cos, b1_sin); | |
37 | |
38 %% demodulate without downsampling and low pass filtering | |
39 b1_cos = a1.heterodyne(plist('f0', fmod, 'ds', false, 'lp', false, 'bw', fmod, 'quad', 'cos')); | |
40 b1_sin = a1.heterodyne(plist('f0', fmod, 'ds', false, 'lp', false, 'bw', fmod, 'quad', 'sin')); | |
41 | |
42 iplot(s, b1_cos, b1_sin); | |
43 | |
44 %% demodulate without downsampling, but with low pass filtering from user input | |
45 filt = miir(plist('type', 'lowpass', 'order', 2, 'fc', 0.2*fmod, 'fs', a1.data.fs)); | |
46 b1_cos = a1.heterodyne(plist('f0', fmod, 'ds', false, 'lp', false, 'bw', fmod, 'quad', 'cos', 'filter', filt)); | |
47 b1_sin = a1.heterodyne(plist('f0', fmod, 'ds', false, 'lp', false, 'bw', fmod, 'quad', 'sin', 'filter', filt)); | |
48 | |
49 iplot(s, b1_cos, b1_sin); |