44
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % UTP_AO_SPLIT a set of UTPs for the ao/split method
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % M Hewitson 06-08-08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % $Id: utp_ao_split_interval.m,v 1.9 2011/09/29 12:09:56 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % <MethodDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % The split method of the ao class splits an analysis object into the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % specified segments. This UTP splits the AOs into sample segments.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % </MethodDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 function results = utp_ao_split_interval(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % Check the inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 if nargin == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % Some keywords
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 class = 'ao';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 mthd = 'split';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 results = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 disp(['**** Running UTPs for ' class '/' mthd]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % Exception list for the UTPs:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % Run the tests
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 results = [results utp_01]; % getInfo call
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 results = [results utp_02]; % Vector input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 results = [results utp_03]; % Matrix input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 results = [results utp_04]; % List input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 results = [results utp_05]; % Test with mixed input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 results = [results utp_06]; % Test history is working
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 results = [results utp_07]; % Test the modify call works
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 results = [results utp_08]; % Test input data shape == output data shape
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 results = [results utp_09]; % Test output of the data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 results = [results utp_10]; % Test with AO which can collapse the x-axis
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 n = 300;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 fs = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 x = 0:(1/fs):(n/fs)-1/fs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 a1 = ao(x, randn(n,1), fs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 pli = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 results = [results utp_11(mthd, a1, ple1, pli)]; % Test plotinfo doesn't disappear
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 results = [results utp_12]; % Test key-words: start_time + duration
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 results = [results utp_13]; % Test key-words: timespan
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 results = [results utp_14]; % Test key-words: start_time + end_time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 results = [results utp_15]; % Test not equal sampled data (tsdata) and 'timeshift' option
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 results = [results utp_16]; % Test not equal sampled data (tsdata) and 'timeshift' option
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 results = [results utp_17]; % Test not equal sampled data (tsdata) and 'timeshift' option
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 disp('Done.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 elseif nargin == 1 % Check for UTP functions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 if strcmp(varargin{1}, 'isutp')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 results = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 results = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 error('### Incorrect inputs')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 %% UTP_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 % Tests that the getInfo call works for this method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 function result = utp_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 % Test that the getInfo call works for no sets, all sets, and each set
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 % individually.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 % Call for no sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 % Call for all sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 io(2) = eval([class '.getInfo(''' mthd ''')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 % Call for each set
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 for kk=1:numel(io(2).sets)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % 1) Check that getInfo call returned an minfo object in all cases.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 % 2) Check that all plists have the correct parameters.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 % check we have minfo objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 if isa(io, 'minfo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 %%% SET 'None'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 idx = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 if ~isempty(io(idx).sets), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 if ~isempty(io(idx).plists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 %%% Check all Sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 idx = 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 if ~any(strcmpi(io(idx).sets, 'Default')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 if ~any(strcmpi(io(idx).sets, 'By times')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 if ~any(strcmpi(io(idx).sets, 'By frequencies')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 if ~any(strcmpi(io(idx).sets, 'By samples')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 if ~any(strcmpi(io(idx).sets, 'By chunks')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 if ~any(strcmpi(io(idx).sets, 'By interval start/end')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 if ~any(strcmpi(io(idx).sets, 'By interval start/duration')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 if ~any(strcmpi(io(idx).sets, 'By interval timespan')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 if numel(io(idx).plists) ~= numel(io(idx).sets), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 %%%%%%%%%% SET 'Default'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 idx = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 if io(idx).plists.nparams ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 if ~io(idx).plists.isparam('times'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 if ~isEmptyDouble(io(idx).plists.find('times')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 if ~isequal(io(idx).plists.getOptionsForParam('times'), {[]}), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 %%%%%%%%%% SET 'By times'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 idx = 4;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 if io(idx).plists.nparams ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 if ~io(idx).plists.isparam('times'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 if ~isEmptyDouble(io(idx).plists.find('times')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 if ~isequal(io(idx).plists.getOptionsForParam('times'), {[]}), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 %%%%%%%%%% SET 'By frequencies'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 idx = 5;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 if io(idx).plists.nparams ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 if ~io(idx).plists.isparam('frequencies'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 if ~isEmptyDouble(io(idx).plists.find('frequencies')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 if ~isequal(io(idx).plists.getOptionsForParam('frequencies'), {[]}), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 %%%%%%%%%% SET 'By samples'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 idx = 6;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 if io(idx).plists.nparams ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 if ~io(idx).plists.isparam('samples'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 if ~isEmptyDouble(io(idx).plists.find('samples')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 if ~isequal(io(idx).plists.getOptionsForParam('samples'), {[]}), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 %%%%%%%%%% SET 'By chunks'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 idx = 7;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 if io(idx).plists.nparams ~= 2, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 if ~io(idx).plists.isparam('N'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 if ~io(idx).plists.isparam('match'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 if ~isEmptyDouble(io(idx).plists.find('N')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 if ~isequal(io(idx).plists.find('match'), true), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 if ~isequal(io(idx).plists.getOptionsForParam('N'), {[]}), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 if ~isequal(io(idx).plists.getOptionsForParam('match'), {true, false}), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 %%%%%%%%%% SET 'By interval start/end'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 idx = 8;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 if io(idx).plists.nparams ~= 2, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 if ~io(idx).plists.isparam('start_time'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 if ~io(idx).plists.isparam('end_time'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 if ~eq(io(idx).plists.find('start_time'), time(0), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 if ~eq(io(idx).plists.find('end_time'), time(0), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 %%%%%%%%%% SET 'By interval start/duration'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 idx = 9;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 if io(idx).plists.nparams ~= 2, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 if ~io(idx).plists.isparam('start_time'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 if ~io(idx).plists.isparam('duration'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 if ~eq(io(idx).plists.find('start_time'), time(0), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 if ~eq(io(idx).plists.find('duration'), time(0), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 %%%%%%%%%% SET 'By interval timespan'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 idx = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 if io(idx).plists.nparams ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 if ~io(idx).plists.isparam('timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 ts = timespan(0,0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 if ~eq(io(idx).plists.find('timespan'), ts, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 end % END UTP_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 %% UTP_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 % Tests that the split method works with a vector of AOs as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 function result = utp_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 % Test that the split method works for a vector of AOs as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 n1 = 300;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 fs1 = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 x1 = 0:(1/fs1):(n1/fs1)-1/fs1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 a1 = ao(x1, randn(n1,1), fs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 n2 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 fs2 = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 x2 = 0:(1/fs2):(n2/fs2)-1/fs2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 a2 = ao(x2, randn(n2,1), fs2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 n3 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 fs3 = .3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 x3 = 0:(1/fs3):(n3/fs3)-1/fs3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 a3 = ao(x3, randn(n3,1), fs3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 a2.setT0(a2.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 a3.setT0(a3.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 avec = [a1, a2, a3];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 out = split(avec, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 % 1) Check that the number of elements in 'out' is the same as in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 % 'avec' times numbers of intervals
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 % 2) Check that each output AO contains the correct data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 if numel(out) ~= numel(avec), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 % Check each output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 for kk=1:2:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 %%%% Check Interval '14:00:25' .. '14:01:15'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 x = avec(kk).x + avec(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 y = avec(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 ts = time(st).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 te = time(et).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 ox = out(kk).x + out(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 oy = out(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 if ~isequal(ox, x(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 if ~isequal(oy, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 end % END UTP_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 %% UTP_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 % Tests that the split method works with a matrix of AOs as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 function result = utp_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 % Tests that the split method works with a matrix of AOs as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 n1 = 300;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 fs1 = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 x1 = 0:(1/fs1):(n1/fs1)-1/fs1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 a1 = ao(x1, randn(n1,1), fs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 n2 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 fs2 = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 x2 = 0:(1/fs2):(n2/fs2)-1/fs2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 a2 = ao(x2, randn(n2,1), fs2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 n3 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 fs3 = .3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 x3 = 0:(1/fs3):(n3/fs3)-1/fs3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 a3 = ao(x3, randn(n3,1), fs3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 a2.setT0(a2.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 a3.setT0(a3.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 amat = [a1, a2, a3; a3, a1, a2];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 out = split(amat, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 % 1) Check that the number of elements in 'out' is the same as in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 % 'amat' times numbers of intervals
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 % 2) Check that each output AO contains the correct data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 if numel(out) ~= numel(amat), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 % Check each output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 for kk=1:2:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 %%%% Check Interval '14:00:25' .. '14:01:15'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 x = amat(kk).x + amat(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 y = amat(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 ts = time(st).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 te = time(et).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 ox = out(kk).x + out(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 oy = out(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 if ~isequal(ox, x(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 if ~isequal(oy, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 end % END UTP_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 %% UTP_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 % Tests that the split method works with a list of AOs as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 function result = utp_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 % Tests that the split method works with a list of AOs as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 n1 = 300;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 fs1 = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 x1 = 0:(1/fs1):(n1/fs1)-1/fs1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 a1 = ao(x1, randn(n1,1), fs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 n2 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 fs2 = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 x2 = 0:(1/fs2):(n2/fs2)-1/fs2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 a2 = ao(x2, randn(n2,1), fs2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 n3 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 fs3 = .3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 x3 = 0:(1/fs3):(n3/fs3)-1/fs3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 a3 = ao(x3, randn(n3,1), fs3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 a2.setT0(a2.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 a3.setT0(a3.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 out = split(a1, a2, a3, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 % 1) Check that the number of elements in 'out' is the same as in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 % 'amat' times numbers of intervals
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 % 2) Check that each output AO contains the correct data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 aoin = [a1, a2, a3];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 if numel(out) ~= numel(aoin), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 % Check each output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 for kk=1:2:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 %%%% Check Interval '14:00:25' .. '14:01:15'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 x = aoin(kk).x + aoin(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 y = aoin(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 ts = time(st).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 te = time(et).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 ox = out(kk).x + out(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 oy = out(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 if ~isequal(ox, x(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 if ~isequal(oy, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 end % END UTP_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 %% UTP_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 % Tests that the split method works with a mix of different shaped AOs as
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 % input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 function result = utp_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 % Tests that the split method works with a mix of different shaped AOs as
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 % input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 n1 = 300;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 fs1 = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 x1 = 0:(1/fs1):(n1/fs1)-1/fs1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 a1 = ao(x1, randn(n1,1), fs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 n2 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 fs2 = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 x2 = 0:(1/fs2):(n2/fs2)-1/fs2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 a2 = ao(x2, randn(n2,1), fs2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 n3 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 fs3 = .3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 x3 = 5000:(1/fs3):5000+((n3/fs3)-1/fs3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 a3 = ao(x3, randn(n3,1), fs3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 a2.setT0(a2.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 a3.setT0(a3.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 out = split(a1, [a2;a1], a3, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 % 1) Check that the number of elements in 'out' is the same as in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 % 'amat' times numbers of intervals
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 % 2) Check that each output AO contains the correct data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 aoin = [a1, a2, a1, a3];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 if numel(out) ~= numel(aoin), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 % Check each output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528 for kk=1:2:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 %%%% Check Interval '14:00:25' .. '14:01:15'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 x = aoin(kk).x + aoin(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531 y = aoin(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 ts = time(st).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 te = time(et).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537 ox = out(kk).x + out(kk).t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 oy = out(kk).y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 if ~isequal(ox, x(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 if ~isequal(oy, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 end % END UTP_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 %% UTP_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556 % Tests that the split method properly applies history.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 function result = utp_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563 % Test that the result of applying the split method can be processed back.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 n1 = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570 fs1 = .3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571 x1 = 5000:1/fs1:5000+((n1/fs1)-1/fs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572 a1 = ao(x1, randn(n1,1), fs1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 out = split(a1, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 % 'split'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590 % 2) Check that the re-built object is the same object as the input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598 if ~strcmp(out.hist.methodInfo.mname, 'split'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599 % The rebuilt object must be the same as 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 if ~eq(mout, out, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 end % END UTP_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 %% UTP_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
611
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
612 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
613 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
614 % The split method can not modify the input AO.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
615 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
616 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
617 function result = utp_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
618
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
619 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
620 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
621 % The split method can not modify the input AO.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
622 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
623 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
624
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
625 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
626 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
627 a1 = ao(5000:5099, randn(100,1), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
628 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
629 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
630 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
631 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
632 amodi = ao(at1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
633 aeq = ao(at1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
634 out = aeq.split(pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
635 amodi.split(pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
636 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
637 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
638 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
639 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
640 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
641
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
642 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
643 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
644 % 1) Nothind to do.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
645 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
646 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
647
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
648 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
649 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
650 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
651 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
652 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
653 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
654 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
655
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
656 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
657 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
658 end % END UTP_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
659
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
660 %% UTP_08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
661
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
662 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
663 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
664 % Test the shape of the output.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
665 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
666 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
667 function result = utp_08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
668
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
669 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
670 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
671 % Test that the split method keeps the data shape of the input object.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
672 % The input AO must be an AO with row data and an AO with column data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
673 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
674 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
675
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
676 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
677 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
678 a1 = ao(5000:5099, randn(100,1), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
679 a2 = ao(5000:5099, randn(100,1).', 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
680 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
681 a2.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
682 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
683 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
684 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
685 out1 = split(a1, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
686 out2 = split(a2, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
687 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
688 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
689 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
690 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
691 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
692 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
693
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
694 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
695 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
696 % 1) Check that the shape of the data doesn't change.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
697 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
698 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
699
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
700 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
701 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
702 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
703 % Check the shape of the output data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
704 if size(out1.data.y,1) == 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
705 if size(out2.data.y,2) == 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
706 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
707 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
708 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
709 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
710
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
711 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
712 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
713 end % END UTP_08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
714
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
715 %% UTP_09
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
716
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
717 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
718 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
719 % Check that the split method pass back the output objects to a list of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
720 % output variables or to a single variable.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
721 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
722 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
723 function result = utp_09
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
724
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
725 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
726 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
727 % Call the method with a list of output variables and with a single
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
728 % output variable. Additionaly check that the rebuild method works on
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
729 % the output.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
730 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
731 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
732
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
733 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
734 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
735 a1 = ao(5000:5099, randn(100,1), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
736 a2 = ao(5000:5099, randn(100,1).', 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
737 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
738 a2.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
739 st = '14:00:25';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
740 et = '14:01:15';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
741 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
742 [o1, o2] = split(a1, a2, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
743 o3 = split(a1, a2, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
744 mout1 = rebuild(o1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
745 mout2 = rebuild(o2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
746 mout3 = rebuild(o3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
747 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
748 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
749 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
750 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
751 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
752 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
753
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
754 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
755 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
756 % 1) Check that the output contains the right number of objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
757 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
758 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
759 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
760
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
761 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
762 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
763 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
764 % Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
765 if numel(o1) ~=1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
766 if numel(o2) ~=1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
767 if numel(o3) ~=2, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
768 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
769 if ~eq(o1, mout1, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
770 if ~eq(o2, mout2, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
771 if ~eq(o3, mout3, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
772 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
773 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
774 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
775 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
776
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
777 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
778 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
779 end % END UTP_09
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
780
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
781 %% UTP_10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
782
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
783 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
784 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
785 % Check that the split method can handle AO which have a collaped x-axis.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
786 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
787 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
788 function result = utp_10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
789
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
790 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
791 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
792 % Check that the split method can handle AO which have a collaped x-axis.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
793 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
794 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
795
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
796 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
797 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
798 plao = plist('fs', 30, 'nsecs', 30, 'waveform', 'sine wave', 'f', 1.23, 'phi', 30);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
799 a1 = ao(plao);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
800 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
801 st = '14:00:07';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
802 et = '14:00:17';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
803 pl = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
804 out = split(a1, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
805 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
806 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
807 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
808 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
809 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
810 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
811 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
812
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
813 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
814 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
815 % 1) Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
816 % 2) Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
817 % 3) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
818 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
819 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
820
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
821 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
822 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
823 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
824 % Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
825 if numel(out) ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
826 % Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
827 x = a1.x + a1.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
828 y = a1.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
829 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
830 ts = time(st).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
831 te = time(et).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
832 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
833 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
834 ox = out.x + out.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
835 oy = out.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
836 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
837 if ~isequal(ox, x(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
838 if ~isequal(oy, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
839 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
840 if ~eq(out, mout, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
841 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
842 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
843 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
844 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
845
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
846 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
847 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
848 end % END UTP_10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
849
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
850
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
851 %% UTP_12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
852
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
853 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
854 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
855 % Check that the split method uses the key-words: start_time and duration
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
856 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
857 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
858 function result = utp_12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
859
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
860 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
861 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
862 % Check that the split method uses the key-words: start_time and
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
863 % duration
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
864 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
865 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
866
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
867 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
868 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
869 a1 = ao(5000:5099, randn(100,1), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
870 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
871 st = format(time('14:01:00')+5000, 'HH:MM:SS');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
872 du = '00:00:10';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
873 plc = plist('start_time', st, 'duration', du);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
874 plo = plist('start_time', time(st), 'duration', time(du));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
875 outc = split(a1, plc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
876 outo = split(a1, plo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
877 moutc = rebuild(outc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
878 mouto = rebuild(outo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
879 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
880 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
881 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
882 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
883 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
884 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
885
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
886 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
887 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
888 % 1) Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
889 % 2) Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
890 % 3) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
891 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
892 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
893
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
894 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
895 TOL = 1e-11;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
896 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
897 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
898 % Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
899 if numel(outc) ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
900 if numel(outo) ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
901 % Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
902 x = a1.x + a1.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
903 y = a1.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
904 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
905 ts = time(st).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
906 te = ts + time(du).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
907 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
908 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
909 oxc = outc.x + outc.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
910 oyc = outc.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
911 oxo = outo.x + outo.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
912 oyo = outo.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
913 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
914 if any(abs(oxc - x(idx)) > TOL), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
915 if ~isequal(oyc, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
916 if any(abs(oxo - x(idx)) > TOL), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
917 if ~isequal(oyo, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
918 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
919 if ~eq(outc, moutc, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
920 if ~eq(outo, mouto, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
921 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
922 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
923 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
924 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
925
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
926 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
927 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
928 end % END UTP_12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
929
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
930 %% UTP_13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
931
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
932 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
933 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
934 % Check that the split method uses the key-words: timespan
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
935 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
936 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
937 function result = utp_13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
938
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
939 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
940 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
941 % Check that the split method uses the key-words: timespan
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
942 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
943 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
944
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
945 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
946 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
947 a1 = ao(5000:5099, randn(100,1), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
948 a1.setT0(a1.t0 + time('14:00:00'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
949 ts = timespan(time('14:00:20')+5e3, time('14:00:50')+5e3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
950 pl = plist('timespan', ts);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
951 out = split(a1, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
952 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
953 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
954 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
955 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
956 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
957 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
958 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
959
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
960 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
961 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
962 % 1) Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
963 % 2) Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
964 % 3) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
965 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
966 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
967
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
968 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
969 TOL = 1e-11;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
970 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
971 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
972 % Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
973 if numel(out) ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
974 % Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
975 x = a1.x + a1.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
976 y = a1.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
977 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
978 ts = double(time('14:00:20')+5e3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
979 te = double(time('14:00:50')+5e3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
980 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
981 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
982 ox = out.x + out.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
983 oy = out.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
984 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
985 if any(abs(ox - x(idx)) > TOL), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
986 if ~isequal(oy, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
987 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
988 if ~eq(out, mout, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
989 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
990 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
991 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
992 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
993
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
994 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
995 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
996 end % END UTP_13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
997
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
998 %% UTP_14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
999
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1000 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1001 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1002 % Check that the split method uses the key-words: start_time and end_time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1003 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1004 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1005 function result = utp_14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1006
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1007 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1008 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1009 % Check that the split method uses the key-words: start_time and end_time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1010 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1011 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1012
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1013 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1014 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1015 a1 = ao(plist('xvals', '0:199', 'yvals', 'randn(200,1)', 'fs', 1, 't0', '14:00:00 2009-02-17'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1016 st = '14:01:40 2009-02-17';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1017 et = '14:03:20 17-02-2009';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1018 plc = plist('start_time', st, 'end_time', et);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1019 plo = plist('start_time', time(st), 'end_time', time(et));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1020 outc = split(a1, plc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1021 outo = split(a1, plo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1022 moutc = rebuild(outc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1023 mouto = rebuild(outo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1024 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1025 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1026 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1027 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1028 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1029 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1030
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1031 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1032 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1033 % 1) Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1034 % 2) Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1035 % 3) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1036 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1037 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1038
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1039 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1040 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1041 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1042 % Check the number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1043 if numel(outc) ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1044 if numel(outo) ~= 1, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1045 % Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1046 x = a1.x + a1.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1047 y = a1.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1048 % Comput start/end time
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1049 ts = time(st).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1050 te = time(et).double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1051 idx = find(x >= ts & x < te);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1052 % Normalize out data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1053 oxc = outc.x + outc.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1054 oyc = outc.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1055 oxo = outo.x + outo.t0.double;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1056 oyo = outo.y;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1057 % Check data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1058 if ~isequal(oxc, x(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1059 if ~isequal(oyc, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1060 if ~isequal(oxo, x(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1061 if ~isequal(oyo, y(idx)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1062 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1063 if ~eq(outc, moutc, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1064 if ~eq(outo, mouto, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1065 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1066 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1067 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1068 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1069
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1070 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1071 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1072 end % END UTP_14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1073
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1074 %% UTP_15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1075
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1076 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1077 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1078 % Check that the split method works with notequal sampled data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1079 % Check that the interval can be passed via two time objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1080 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1081 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1082 function result = utp_15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1083
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1084 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1085 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1086 % Check that the split method works with notequal sampled data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1087 % Check that the interval can be passed via two time objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1088 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1089 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1090
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1091 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1092 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1093 x = [1:1018 1020:1999 2001:3000 3002:6500 6502:7000 7002:10000];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1094 y = randn(1e4,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1095 y = y(x); % Use the x values as an index
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1096 a1 = ao(plist('xvals', x, 'yvals', y, 'fs', 1, 't0', '2009-11-03 18:00:00.000', 'yunits', 'N'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1097
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1098 start_time = time('2009-11-03 18:10:00.000');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1099 end_time = time('2009-11-03 18:20:00.000');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1100
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1101 pl1 = plist(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1102 'start_time', start_time, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1103 'end_time', end_time);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1104 out1 = split(a1, pl1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1105 mout1 = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1106 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1107 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1108 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1109 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1110 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1111 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1112
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1113 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1114 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1115 % 1) Check the outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1116 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1117 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1118 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1119
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1120 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1121 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1122 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1123
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1124 % Check number of seconds
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1125 dt = double(end_time - start_time);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1126 if out1.nsecs ~= dt, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1127 % Check t0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1128 dt0 = double(out1.t0 - a1.t0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1129 if dt0 ~= 0, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1130 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1131 if ~eq(out1, mout1, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1132 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1133 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1134 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1135 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1136
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1137 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1138 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1139 end % END UTP_15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1140
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1141
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1142 %% UTP_16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1143
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1144 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1145 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1146 % Check that the split method works with notequal sampled data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1147 % Check that the interval can be passed via two time strings.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1148 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1149 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1150 function result = utp_16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1151
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1152 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1153 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1154 % Check that the split method works with notequal sampled data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1155 % Check that the interval can be passed via two time strings.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1156 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1157 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1158
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1159 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1160 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1161 x = [1:1018 1020:1999 2001:3000 3002:6500 6502:7000 7002:10000];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1162 y = randn(1e5, 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1163 y = y(x); % Use the x values as an index
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1164 a1 = ao(plist('xvals', x, 'yvals', y, 'fs', 1, 't0', '2009-11-03 18:00:00.000', 'yunits', 'N'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1165
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1166 start_time = '2009-11-03 18:10:00.000';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1167 end_time = '2009-11-03 18:20:00.000';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1168
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1169 pl1 = plist(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1170 'start_time', start_time, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1171 'end_time', end_time);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1172 out1 = split(a1, pl1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1173 mout1 = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1174 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1175 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1176 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1177 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1178 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1179 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1180
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1181 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1182 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1183 % 1) Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1184 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1185 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1186 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1187
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1188 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1189 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1190 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1191
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1192 % Check number of seconds
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1193 dt = double(time(end_time) - time(start_time));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1194 if out1.nsecs ~= dt, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1195 % Check t0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1196 dt0 = double(out1.t0 - a1.t0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1197 if dt0 ~= 0, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1198 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1199 if ~eq(out1, mout1, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1200 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1201 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1202 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1203 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1204
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1205 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1206 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1207 end % END UTP_16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1208
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1209 %% UTP_17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1210
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1211 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1212 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1213 % Check that the split method works with notequal sampled data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1214 % Check that the interval can be passed via one timespan object.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1215 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1216 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1217 function result = utp_17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1218
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1219 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1220 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1221 % Check that the split method works with notequal sampled data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1222 % Check that the interval can be passed via one timespan object.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1223 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1224 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1225
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1226 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1227 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1228 x = [1:1018 1020:1999 2001:3000 3002:6500 6502:7000 7002:10000];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1229 y = randn(1e5, 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1230 y = y(x); % Use the x values as an index
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1231 a1 = ao(plist('xvals', x, 'yvals', y, 'fs', 1, 't0', '2009-11-03 18:00:00.000', 'yunits', 'N'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1232
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1233 start_time = '2009-11-03 18:10:00.000';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1234 end_time = '2009-11-03 18:15:00.000';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1235
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1236 time_range = timespan(start_time, end_time);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1237
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1238 pl1 = plist(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1239 'timespan', time_range);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1240 out1 = split(a1, pl1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1241 mout1 = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1242 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1243 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1244 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1245 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1246 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1247 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1248
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1249 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1250 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1251 % 1) Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1252 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1253 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1254 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1255
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1256 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1257 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1258 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1259
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1260 % Check number of seconds
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1261 dt = double(time_range.endT - time_range.startT);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1262 if out1.nsecs ~= dt, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1263 % Check t0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1264 dt0 = double(out1.t0 - a1.t0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1265 if dt0 ~= 0, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1266 % Check the rebuilding of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1267 if ~eq(out1, mout1, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1268 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1269 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1270 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1271 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1272
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1273 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1274 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1275 end % END UTP_17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1276
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1277 end
|