Mercurial > hg > ltpda
comparison m-toolbox/test/test_ao_split.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 split method. | |
2 % | |
3 % M Hewitson 02-03-07 | |
4 % | |
5 % $Id: test_ao_split.m,v 1.18 2010/05/06 09:33:49 nicolodi Exp $ | |
6 % | |
7 function test_ao_split() | |
8 | |
9 % Make test AOs | |
10 | |
11 nsecs = 10; | |
12 fs = 1000; | |
13 | |
14 pl = plist('nsecs', nsecs, 'fs', fs, 'tsfcn', 'randn(size(t))'); | |
15 | |
16 a1 = ao(pl); | |
17 a1 = a1.setName; | |
18 | |
19 % Split by time | |
20 times = [0.0 1.0 1.0 2.5 2.0 3.0]; | |
21 pl = plist('times', times); | |
22 b = split(a1, pl); | |
23 | |
24 % Plot | |
25 | |
26 iplot(a1, b) | |
27 | |
28 b1 = b(2); | |
29 plot(b1.hist) | |
30 | |
31 % Recreate from history | |
32 a_out = rebuild(b(1)); | |
33 | |
34 iplot(a_out) | |
35 plot(a_out.hist) | |
36 | |
37 % Construct an AO | |
38 a1 = ao(plist('waveform', 'sine', 'f', 0.1, 'a', 1, 'fs', 10, 'nsecs', 10)); | |
39 | |
40 % This should just remove the first data point | |
41 a2 = split(a1, plist('times', [0.05 0])); | |
42 | |
43 % Check | |
44 assert(all(a2.y == a1.y(2:end))); | |
45 assert(all(((a2.x + a2.t0.utc_epoch_milli/1000.0) - (a1.x(2:end) + a1.t0.utc_epoch_milli/1000.0)) < 2*eps(a2.x))); | |
46 | |
47 iplot(a1, a2, plist('markers', {'+','+'})); | |
48 | |
49 end | |
50 % END |