Mercurial > hg > ltpda
comparison testing/utp_1.1/utp_fcns/get_test_objects_ao.m @ 44:409a22968d5e default
Add unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Tue, 06 Dec 2011 18:42:11 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
43:bc767aaa99a8 | 44:409a22968d5e |
---|---|
1 % GET_TEST_OBJECTS_AO returns a set of AOs suitable for many of the UTPs | |
2 % | |
3 % CALL: [at1,at2,at3,at4,at5,at6,atvec,atmat] = get_test_objects_ao(); | |
4 % | |
5 % OUTPUTS: | |
6 % at1 - a tsdata AO containing 2 seconds of a 1.23Hz sine wave sampled at 10Hz. | |
7 % at2 - an fsdata AO containing 1000 samples of white noise | |
8 % at3 - an xydata AO containing 100 data samples | |
9 % at4 - a cdata AO containing a 3x3 matrix | |
10 % at5 - a tsdata AO containing 30s of noise at 10Hz (data-vector = row vector) | |
11 % at6 - a tsdata AO containing 30s of different noise at 10Hz (data-vector = column vector) | |
12 % atvec - a vector of AOs containing [at1 at3 at3] | |
13 % atmat - a matrix of AOs containing [at1 at2 at3; at4 at5 at6] | |
14 % | |
15 % M Hewitson 06-08-08 | |
16 % | |
17 % $Id: get_test_objects_ao.m,v 1.8 2011/04/01 08:07:25 mauro Exp $ | |
18 % | |
19 function [at1,at2,at3,at4,at5,at6,atvec,atmat] = get_test_objects_ao | |
20 | |
21 %% Single AO containing a sine wave | |
22 fs = 10; | |
23 pl1 = plist(); | |
24 pl1.append('fs', fs); | |
25 pl1.append('nsecs', 30); | |
26 pl1.append('waveform', 'sine wave'); | |
27 pl1.append('f', 1.23); | |
28 pl1.append('phi', 30); | |
29 at1 = ao(pl1); | |
30 | |
31 | |
32 % Single AO containing an xydata object | |
33 x = 1:100; | |
34 y = exp(x.^.5/2); | |
35 at3 = ao(x,y, plist('type', 'xydata')); | |
36 | |
37 %% Single AO with a matrix | |
38 at4 = ao([1 -2 3; 4 5 -6; -7 8 9]); | |
39 | |
40 %% Single AO with 30s of noise | |
41 at5 = ao(plist('tsfcn', 'randn(size(t))', 'nsecs', 30, 'fs', fs)); | |
42 at5.setDy(at5.y*.1); | |
43 | |
44 %% Single AO with 30s of noise | |
45 at6 = ao(plist('tsfcn', 'randn(size(t)).''', 'nsecs', 30, 'fs', fs)); | |
46 | |
47 %% Single AO containing some fsdata | |
48 at2 = psd(at5); | |
49 at2.setDy(at2.y*.1); | |
50 | |
51 %% Set AOs yunits | |
52 | |
53 % Pick units and prefix from those supported | |
54 unit_list = unit.supportedUnits; | |
55 % remove the first empty unit '' from the list, because then is it | |
56 % possible that we add a prefix to an empty unit | |
57 unit_list = unit_list(2:end); | |
58 prefix_list = unit.supportedPrefixes; | |
59 | |
60 % Set units by choosing a random prefix and a random unit | |
61 at1.setYunits(... | |
62 unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))])); | |
63 at2.setYunits(... | |
64 unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))])); | |
65 at3.setYunits(... | |
66 unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))])); | |
67 at4.setYunits(... | |
68 unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))])); | |
69 at5.setYunits(... | |
70 unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))])); | |
71 at6.setYunits(... | |
72 unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))])); | |
73 | |
74 %% Vector of AOs | |
75 atvec = [at2 at5 at6]; | |
76 | |
77 %% Matrix of AOs | |
78 atmat = [at1 at2 at3; at4 at5 at6]; | |
79 | |
80 %% Set AO names. | |
81 % Don't remove the setting of the AO names and it must be at the last position. | |
82 at1.setName; | |
83 at2.setName; | |
84 at3.setName; | |
85 at4.setName; | |
86 at5.setName; | |
87 at6.setName; | |
88 | |
89 end | |
90 |