comparison testing/utp_1.1/utps/ao/utp_ao_ao.m @ 45:a59cdb8aaf31 database-connection-manager

Merge
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 19:07:22 +0100
parents 409a22968d5e
children
comparison
equal deleted inserted replaced
42:f90d4f666cc7 45:a59cdb8aaf31
1 % UTP_AO_AO a set of UTPs for the ao/ao method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_ao_ao.m,v 1.73 2011/08/15 10:44:51 hewitson Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The ao method of the ao class constructs AOs.
11 %
12 % </MethodDescription>
13
14 function results = utp_ao_ao(varargin)
15
16 % Check the inputs
17 if nargin == 0
18
19 % Some keywords
20 class = 'ao';
21 mthd = 'ao';
22
23 results = [];
24 disp('******************************************************');
25 disp(['**** Running UTPs for ' class '/' mthd]);
26 disp('******************************************************');
27
28 % Test AOs
29 [at1,at2,at3,at4,at5,at6,atvec,atmat] = eval(['get_test_objects_' class]);
30
31 % Exception list for the UTPs:
32 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
33
34 % Define THRESHOLD for computing error
35 TOL = 1e-14;
36
37 % Run the tests
38 results = [results utp_01]; % getInfo call
39 results = [results utp_02(mthd, atvec, [], [], ple3)]; % Vector input
40 results = [results utp_03(mthd, atmat, [], [], ple3)]; % Matrix input
41 results = [results utp_04(mthd, at1, at2, at3, [], [], ple3)]; % List input
42 results = [results utp_05(mthd, at1, atvec, atmat, [], [], ple3)]; % Test with mixed input
43 results = [results utp_06(mthd, at1, [], ple2)]; % Test history is working
44
45 % Old format
46 results = [results utp_08]; % Test history is working with ASCII file constructor
47 results = [results utp_09]; % Test history is working with complex ASCII file constructor
48 results = [results utp_13]; % Test history is working with vals constructor
49 results = [results utp_15]; % Test history is working with plist(fcn) constructor
50 results = [results utp_16]; % Test history is working with plist(vals) constructor
51 results = [results utp_17]; % Test history is working with plist(x/y-vals) constructor
52 results = [results utp_18]; % Test history is working with plist(tsfcn) constructor
53 results = [results utp_19]; % Test history is working with plist(fsfcn) constructor
54 results = [results utp_20]; % Test history is working with plist(win) constructor
55 results = [results utp_21]; % Test history is working with plist(waveform) constructor
56 results = [results utp_23]; % Test history is working with plist(polynomial) constructor
57 results = [results utp_25]; % Test history is working with specwin constructor
58 results = [results utp_26]; % Test history is working with data-objects constructor
59 results = [results utp_28]; % Test history is working with x-vector, y-vector constructor
60 results = [results utp_29]; % Test history is working with filename + plist constructor
61 results = [results utp_30]; % Test history is working with filename + plist constructor
62 results = [results utp_31]; % Test history is working with filename + plist constructor
63
64 % constructor specific tests
65 results = [results utp_60(class, at3, ple2)]; % Test history is properly handled with MAT file constructor
66 results = [results utp_61(class, at1, ple2)]; % Test history is properly handled with XML file constructor
67 results = [results utp_62(class, at1, at2, ple2)]; % Test history is working with struct constructor
68 % results = [results utp_63(class, ple1)]; % Test history is working with pzmodel-object constructor
69 results = [results utp_64(class, at1, ple1, ple2)]; % Test history is working with plist(filename) constructor
70 results = [results utp_65(class, at1, ple3)]; % Test history is working with plist(hostname) constructor
71 results = [results utp_66(class, ple1)]; % Test history is working with plist(pzmodel) constructor
72 results = [results utp_67(class, ple1)]; % Test history is working with pzmodel + plist constructor
73 results = [results utp_68(class, at1, ple3)]; % Test history is working with conn+Id constructor
74
75 disp('Done.');
76 disp('******************************************************');
77
78 elseif nargin == 1 % Check for UTP functions
79 if strcmp(varargin{1}, 'isutp')
80 results = 1;
81 elseif strcmpi(varargin{1}, 'needs repository')
82 results = 2;
83 else
84 results = 0;
85 end
86 else
87 error('### Incorrect inputs')
88 end
89
90 %% UTP_01
91
92 % <TestDescription>
93 %
94 % Tests that the getInfo call works for this method.
95 %
96 % </TestDescription>
97 function result = utp_01
98
99
100 % <SyntaxDescription>
101 %
102 % Test that the getInfo call works for no sets, all sets, and each set
103 % individually.
104 %
105 % </SyntaxDescription>
106
107 msg = '';
108 try
109 % <SyntaxCode>
110 % Call for no sets
111 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
112 % Call for all sets
113 io(2) = eval([class '.getInfo(''' mthd ''')']);
114 % Call for each set
115 for kk=1:numel(io(2).sets)
116 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
117 end
118 % </SyntaxCode>
119 stest = true;
120 catch err
121 disp(err.message)
122 msg = err.message;
123 stest = false;
124 end
125
126 % <AlgoDescription>
127 %
128 % 1) Check that getInfo call returned an minfo object in all cases.
129 % 2) Check that all plists have the correct parameters.
130 %
131 % </AlgoDescription>
132
133 atest = true;
134 if stest
135 % <AlgoCode>
136 % check we have minfo objects
137 if isa(io, 'minfo')
138 prefs = getappdata(0, 'LTPDApreferences');
139
140 % SET 'None'
141 if ~isempty(io(1).sets), atest = false; msg = 'Sets ''None'' isn''t empty.'; end
142 if ~isempty(io(1).plists), atest = false; msg = 'First plist for all sets isn''t empty.'; end
143 % Check number of SETS
144 if numel(io(2).sets) ~= 21, atest = false; msg = 'Number of sets is wrong'; end
145 % Check all Sets
146 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; msg = 'Sets array does not contain ''Default'''; end
147 if ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; msg = 'Sets array does not contain ''From MAT File'''; end
148 if ~any(strcmpi(io(2).sets, 'From XML File')), atest = false; msg = 'Sets array does not contain ''From XML File'''; end
149 if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; msg = 'Sets array does not contain ''From Repository'''; end
150 if ~any(strcmpi(io(2).sets, 'From Built-in model')), atest = false; msg = 'Sets array does not contain ''From Built-in Model'''; end
151 if ~any(strcmpi(io(2).sets, 'From MAT Data File')), atest = false; msg = 'Sets array does not contain ''From MAT Data File'''; end
152 if ~any(strcmpi(io(2).sets, 'From ASCII File')), atest = false; msg = 'Sets array does not contain ''From ASCII File'''; end
153 if ~any(strcmpi(io(2).sets, 'From Complex ASCII File')), atest = false; msg = 'Sets array does not contain ''From Complex ASCII File'''; end
154 if ~any(strcmpi(io(2).sets, 'From Function')), atest = false; msg = 'Sets array does not contain ''From Function'''; end
155 if ~any(strcmpi(io(2).sets, 'From Values')), atest = false; msg = 'Sets array does not contain ''From Values'''; end
156 if ~any(strcmpi(io(2).sets, 'From XY Values')), atest = false; msg = 'Sets array does not contain ''From XY Values''';end
157 if ~any(strcmpi(io(2).sets, 'From Time-series Function')), atest = false; msg = 'Sets array does not contain ''From Time-series Function'''; end
158 if ~any(strcmpi(io(2).sets, 'From XY Function')), atest = false; msg = 'Sets array does not contain ''From XY Function'''; end
159 if ~any(strcmpi(io(2).sets, 'From Frequency-series Function')), atest = false; msg = 'Sets array does not contain ''From Frequency-series Function'''; end
160 if ~any(strcmpi(io(2).sets, 'From Window')), atest = false; msg = 'Sets array does not contain ''From Window'''; end
161 if ~any(strcmpi(io(2).sets, 'From Waveform')), atest = false; msg = 'Sets array does not contain ''From Waveform''';end
162 if ~any(strcmpi(io(2).sets, 'From Polynomial')), atest = false; msg = 'Sets array does not contain ''From Polynomial''';end
163 if ~any(strcmpi(io(2).sets, 'From Pzmodel')), atest = false; msg = 'Sets array does not contain ''From Pzmodel''';end
164 if ~any(strcmpi(io(2).sets, 'From smodel')), atest = false; msg = 'Sets array does not contain ''From smodel''';end
165 if ~any(strcmpi(io(2).sets, 'From pest')), atest = false; msg = 'Sets array does not contain ''From pest''';end
166 if ~any(strcmpi(io(2).sets, 'From Parameter')), atest = false; msg = 'Sets array does not contain ''From Parameter'''; end
167 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; msg = 'Number of plists does not match number of sets'; end
168 %%%%%%%%%% SET 'Default'
169 % Check key
170 pn = 3;
171 [atest, msg] = checkParamNumber(io, pn, 3);
172 % Check default value
173 % Check options
174 %%%%%%%%%% SET 'From MAT File'
175 pn = 4;
176 [atest, msg] = checkParamNumber(io, pn, 1);
177 % Check key
178 if ~io(pn).plists.isparam('filename'), atest = false; end
179 % Check default value
180 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
181 % Check options
182 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end
183 %%%%%%%%%% SET 'From XML File'
184 pn = 5;
185 [atest, msg] = checkParamNumber(io, pn, 1);
186 % Check key
187 if ~io(pn).plists.isparam('filename'), atest = false; end
188 % Check default value
189 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
190 % Check options
191 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end
192 %%%%%%%%%% SET 'From Repository'
193 pn = 6;
194 [atest, msg] = checkParamNumber(io, pn, 7);
195 % Check key
196 if ~io(pn).plists.isparam('hostname'), atest = false; end
197 if ~io(pn).plists.isparam('id'), atest = false; end
198 if ~io(pn).plists.isparam('cid'), atest = false; end
199 if ~io(pn).plists.isparam('database'), atest = false; end
200 if ~io(pn).plists.isparam('binary'), atest = false; end
201 if ~io(pn).plists.isparam('username'), atest = false; end
202 if ~io(pn).plists.isparam('password'), atest = false; end
203 % Check default value
204 if ~isEmptyDouble(io(pn).plists.find('id')), atest = false; end
205 if ~isEmptyDouble(io(pn).plists.find('cid')), atest = false; end
206 if ~isequal(io(pn).plists.find('binary'), 'yes'), atest = false; end
207 % Check options
208 if ~isequal(io(pn).plists.getOptionsForParam('id'), {[]}), atest = false; end
209 if ~isequal(io(pn).plists.getOptionsForParam('cid'), {[]}), atest = false; end
210 if ~isequal(io(pn).plists.getOptionsForParam('binary'), {'yes', 'no'}), atest = false; end
211 %%%%%%%%%% SET 'From Built-in model'
212 pn = 7;
213 [atest, msg] = checkParamNumber(io, pn, 1);
214 % Check key
215 if ~io(pn).plists.isparam('built-in'), atest = false; end
216 % Check default value
217 if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end
218 % Check options
219 if ~isequal(io(pn).plists.getOptionsForParam('built-in'), {''}), atest = false; end
220 %%%%%%%%%% SET 'From MAT Data File'
221 pn = 8;
222 [atest, msg] = checkParamNumber(io, pn, 9);
223 % Check key
224 if ~io(pn).plists.isparam('name'), atest = false; end
225 if ~io(pn).plists.isparam('description'), atest = false; end
226 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
227 if ~io(pn).plists.isparam('filename'), atest = false; end
228 if ~io(pn).plists.isparam('type'), atest = false; end
229 if ~io(pn).plists.isparam('columns'), atest = false; end
230 if ~io(pn).plists.isparam('xunits'), atest = false; end
231 if ~io(pn).plists.isparam('yunits'), atest = false; end
232 if ~io(pn).plists.isparam('fs'), atest = false; end
233 % Check default value
234 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
235 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
236 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
237 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
238 if ~isequal(io(pn).plists.find('type'), 'cdata'), atest = false; end
239 if ~isEmptyDouble(io(pn).plists.find('columns')), atest = false; end
240 if ~isequal(io(pn).plists.find('xunits'), 's'), atest = false; end
241 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
242 if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end
243 % Check options
244 if ~isequal(io(pn).plists.getOptionsForParam('name'), {''}), atest = false; end
245 if ~isequal(io(pn).plists.getOptionsForParam('description'), {''}), atest = false; end
246 % not sure how to test this
247 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end
248 if ~isequal(io(pn).plists.getOptionsForParam('type'), {'tsdata', 'fsdata', 'xydata', 'cdata'}), atest = false; end
249 if ~isequal(io(pn).plists.getOptionsForParam('columns'), {[]}), atest = false; end
250 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'s'}), atest = false; end
251 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
252 if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end
253 %%%%%%%%%% SET 'From ASCII File'
254 pn = 9;
255 [atest, msg] = checkParamNumber(io, pn, 14);
256 % Check key
257 if ~io(pn).plists.isparam('name'), atest = false; end
258 if ~io(pn).plists.isparam('description'), atest = false; end
259 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
260 if ~io(pn).plists.isparam('filename'), atest = false; end
261 if ~io(pn).plists.isparam('type'), atest = false; end
262 if ~io(pn).plists.isparam('columns'), atest = false; end
263 if ~io(pn).plists.isparam('xunits'), atest = false; end
264 if ~io(pn).plists.isparam('t0'), atest = false; end
265 if ~io(pn).plists.isparam('yunits'), atest = false; end
266 if ~io(pn).plists.isparam('comment_char'), atest = false; end
267 if ~io(pn).plists.isparam('maxlines'), atest = false; end
268 if ~io(pn).plists.isparam('fs'), atest = false; end
269 if ~io(pn).plists.isparam('robust'), atest = false; end
270 if ~io(pn).plists.isparam('delimiter'), atest = false; end
271 % Check default value
272 if ~isequal(io(pn).plists.find('name'), ''), atest = false; end
273 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
274 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
275 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
276 if ~isequal(io(pn).plists.find('type'), 'cdata'), atest = false; end
277 if ~isEmptyDouble(io(pn).plists.find('columns')), atest = false; end
278 if ~isEmptyChar(io(pn).plists.find('xunits')), atest = false; end
279 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
280 if ~isequal(double(time(io(pn).plists.find('t0'))), 0), atest = false; end
281 if ~isEmptyChar(io(pn).plists.find('comment_char')), atest = false; end
282 if ~isEmptyDouble(io(pn).plists.find('maxlines')), atest = false; end
283 if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end
284 if ~isequal(io(pn).plists.find('robust'), 'no'), atest = false; end
285 if ~isequal(io(pn).plists.find('delimiter'), ''), atest = false; end
286 % Check options
287 if ~isequal(io(pn).plists.getOptionsForParam('name'), {''}), atest = false; end
288 if ~isequal(io(pn).plists.getOptionsForParam('description'), {''}), atest = false; end
289 % not sure how to test this
290 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end
291 if ~isequal(io(pn).plists.getOptionsForParam('type'), {'tsdata', 'fsdata', 'xydata', 'cdata'}), atest = false; end
292 if ~isequal(io(pn).plists.getOptionsForParam('columns'), {[]}), atest = false; end
293 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {''}), atest = false; end
294 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
295 if ~isequal(io(pn).plists.getOptionsForParam('comment_char'), {''}), atest = false; end
296 if ~isequal(io(pn).plists.getOptionsForParam('maxlines'), {[]}), atest = false; end
297 if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end
298 if ~isequal(io(pn).plists.getOptionsForParam('robust'), {'yes', 'no'}), atest = false; end
299 if ~isequal(io(pn).plists.getOptionsForParam('delimiter'), {''}), atest = false; end
300 if ~isequal(io(pn).plists.getOptionsForParam('t0'), {'1970-01-01 00:00:00.000'}), atest = false; end
301 %%%%%%%%%% SET 'From Complex ASCII File'
302 pn = 10;
303 [atest, msg] = checkParamNumber(io, pn, 11);
304 % Check key
305 if ~io(pn).plists.isparam('name'), atest = false; end
306 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
307 if ~io(pn).plists.isparam('description'), atest = false; end
308 if ~io(pn).plists.isparam('filename'), atest = false; end
309 if ~io(pn).plists.isparam('complex_type'), atest = false; end
310 if ~io(pn).plists.isparam('t0'), atest = false; end
311 if ~io(pn).plists.isparam('type'), atest = false; end
312 if ~io(pn).plists.isparam('columns'), atest = false; end
313 if ~io(pn).plists.isparam('xunits'), atest = false; end
314 if ~io(pn).plists.isparam('yunits'), atest = false; end
315 if ~io(pn).plists.isparam('comment_char'), atest = false; end
316 % Check default value
317 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
318 if ~strcmp(io(pn).plists.find('complex_type'), 'real/imag'), atest = false; end
319 if ~strcmp(io(pn).plists.find('type'), 'fsdata'), atest = false; end
320 if ~isequal(io(pn).plists.find('columns'), [1 2 3]), atest = false; end
321 if ~isequal(io(pn).plists.find('xunits'), 'Hz'), atest = false; end
322 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
323 if ~isEmptyChar(io(pn).plists.find('comment_char')), atest = false; end
324 % Check options
325 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end
326 if ~isequal(io(pn).plists.getOptionsForParam('complex_type'), { 'real/imag', 'abs/deg', 'dB/deg', 'abs/rad', 'dB/rad'}), atest = false; end
327 if ~isequal(io(pn).plists.getOptionsForParam('type'), {'tsdata', 'fsdata', 'xydata', 'cdata'}), atest = false; end
328 if ~isequal(io(pn).plists.getOptionsForParam('columns'), {[1 2 3]}), atest = false; end
329 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'Hz'}), atest = false; end
330 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
331 if ~isequal(io(pn).plists.getOptionsForParam('comment_char'), {''}), atest = false; end
332 %%%%%%%%%% SET 'From Function'
333 pn = 11;
334 [atest, msg] = checkParamNumber(io, pn, 5);
335 % Check key
336 if ~io(pn).plists.isparam('name'), atest = false; end
337 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
338 if ~io(pn).plists.isparam('description'), atest = false; end
339 if ~io(pn).plists.isparam('fcn'), atest = false; end
340 if ~io(pn).plists.isparam('yunits'), atest = false; end
341 % Check default value
342 if ~isEmptyChar(io(pn).plists.find('fcn')), atest = false; end
343 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
344 % Check options
345 if ~isequal(io(pn).plists.getOptionsForParam('fcn'), {''}), atest = false; end
346 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
347 %%%%%%%%%% SET 'From Values'
348 pn = 12;
349 [atest, msg] = checkParamNumber(io, pn, 6);
350 % Check key
351 if ~io(pn).plists.isparam('name'), atest = false; end
352 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
353 if ~io(pn).plists.isparam('description'), atest = false; end
354 if ~io(pn).plists.isparam('vals'), atest = false; end
355 if ~io(pn).plists.isparam('n'), atest = false; end
356 if ~io(pn).plists.isparam('yunits'), atest = false; end
357 % Check default value
358 if ~isEmptyDouble(io(pn).plists.find('vals')), atest = false; end
359 if ~isequal(io(pn).plists.find('n'), 1), atest = false; end
360 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
361 % Check options
362 if ~isequal(io(pn).plists.getOptionsForParam('vals'), {[]}), atest = false; end
363 if ~isequal(io(pn).plists.getOptionsForParam('n'), {[1]}), atest = false; end
364 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
365 %%%%%%%%%% SET 'From XY Values'
366 pn = 13;
367 [atest, msg] = checkParamNumber(io, pn, 11);
368 % Check key
369 if ~io(pn).plists.isparam('name'), atest = false; end
370 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
371 if ~io(pn).plists.isparam('description'), atest = false; end
372 if ~io(pn).plists.isparam('type'), atest = false; end
373 if ~io(pn).plists.isparam('fs'), atest = false; end
374 if ~io(pn).plists.isparam('t0'), atest = false; end
375 if ~io(pn).plists.isparam('toffset'), atest = false; end
376 if ~io(pn).plists.isparam('xvals'), atest = false; end
377 if ~io(pn).plists.isparam('yvals'), atest = false; end
378 if ~io(pn).plists.isparam('xunits'), atest = false; end
379 if ~io(pn).plists.isparam('yunits'), atest = false; end
380 if ~io(pn).plists.isparam('t0'), atest = false; end
381 % Check default value
382 if ~isequal(io(pn).plists.find('type'), ''), atest = false; end
383 if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end
384 if ~isequal(double(time(io(pn).plists.find('t0'))), 0), atest = false; end
385 if ~isequal(io(pn).plists.find('toffset'), 0), atest = false; end
386 if ~isEmptyDouble(io(pn).plists.find('xvals')), atest = false; end
387 if ~isEmptyDouble(io(pn).plists.find('yvals')), atest = false; end
388 if ~isEmptyChar(io(pn).plists.find('xunits')), atest = false; end
389 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
390 if ~isequal(io(pn).plists.find('t0'), '1970-01-01 00:00:00.000'), atest = false; end
391 % Check options
392 if ~isequal(io(pn).plists.getOptionsForParam('type'), {'', 'tsdata', 'fsdata', 'xydata', 'cdata'}), atest = false; end
393 if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end
394 if ~isequal(io(pn).plists.getOptionsForParam('xvals'), {[]}), atest = false; end
395 if ~isequal(io(pn).plists.getOptionsForParam('yvals'), {[]}), atest = false; end
396 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {''}), atest = false; end
397 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
398 if ~isequal(io(pn).plists.getOptionsForParam('t0'), {'1970-01-01 00:00:00.000'}), atest = false; end
399 %%%%%%%%%% SET 'From Time-series Function'
400 pn = 14;
401 [atest, msg] = checkParamNumber(io, pn, 9);
402 % Check key
403 if ~io(pn).plists.isparam('name'), atest = false; end
404 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
405 if ~io(pn).plists.isparam('description'), atest = false; end
406 if ~io(pn).plists.isparam('tsfcn'), atest = false; end
407 if ~io(pn).plists.isparam('fs'), atest = false; end
408 if ~io(pn).plists.isparam('nsecs'), atest = false; end
409 if ~io(pn).plists.isparam('t0'), atest = false; end
410 if ~io(pn).plists.isparam('xunits'), atest = false; end
411 if ~io(pn).plists.isparam('yunits'), atest = false; end
412 % Check default value
413 if ~isequal(io(pn).plists.find('tsfcn'), 't'), atest = false; end
414 if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end
415 if ~isEmptyDouble(io(pn).plists.find('nsecs')), atest = false; end
416 if ~isequal(double(time(io(pn).plists.find('t0'))), 0), atest = false; end
417 if ~isequal(io(pn).plists.find('xunits'), 's'), atest = false; end
418 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
419 % Check options
420 if ~isequal(io(pn).plists.getOptionsForParam('tsfcn'), {'t'}), atest = false; end
421 if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end
422 if ~isequal(io(pn).plists.getOptionsForParam('nsecs'), {[]}), atest = false; end
423 if ~isequal(io(pn).plists.getOptionsForParam('t0'), {'1970-01-01 00:00:00.000'}), atest = false; end
424 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'s'}), atest = false; end
425 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
426 %%%%%%%%%% SET 'From XY Function'
427 pn = 15;
428 [atest, msg] = checkParamNumber(io, pn, 7);
429 % Check key
430 if ~io(pn).plists.isparam('name'), atest = false; end
431 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
432 if ~io(pn).plists.isparam('description'), atest = false; end
433 if ~io(pn).plists.isparam('xyfcn'), atest = false; end
434 if ~io(pn).plists.isparam('x'), atest = false; end
435 if ~io(pn).plists.isparam('xunits'), atest = false; end
436 if ~io(pn).plists.isparam('yunits'), atest = false; end
437 % Check default value
438 if ~isequal(io(pn).plists.find('xyfcn'), 'x'), atest = false; end
439 if ~isEmptyDouble(io(pn).plists.find('x')), atest = false; end
440 if ~isequal(io(pn).plists.find('xunits'), ''), atest = false; end
441 if ~isequal(io(pn).plists.find('yunits'), ''), atest = false; end
442 % Check options
443 if ~isequal(io(pn).plists.getOptionsForParam('xyfcn'), {'x'}), atest = false; end
444 if ~isequal(io(pn).plists.getOptionsForParam('x'), {[]}), atest = false; end
445 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {''}), atest = false; end
446 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
447 %%%%%%%%%% SET 'From Frequency-series Function'
448 pn = 16;
449 [atest, msg] = checkParamNumber(io, pn, 11);
450 % Check key
451 if ~io(pn).plists.isparam('name'), atest = false; end
452 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
453 if ~io(pn).plists.isparam('description'), atest = false; end
454 if ~io(pn).plists.isparam('fsfcn'), atest = false; end
455 if ~io(pn).plists.isparam('f1'), atest = false; end
456 if ~io(pn).plists.isparam('f2'), atest = false; end
457 if ~io(pn).plists.isparam('nf'), atest = false; end
458 if ~io(pn).plists.isparam('scale'), atest = false; end
459 if ~io(pn).plists.isparam('f'), atest = false; end
460 if ~io(pn).plists.isparam('xunits'), atest = false; end
461 if ~io(pn).plists.isparam('yunits'), atest = false; end
462 % Check default value
463 if ~isequal(io(pn).plists.find('fsfcn'), 'f'), atest = false; end
464 if ~isequal(io(pn).plists.find('f1'), 1e-9), atest = false; end
465 if ~isequal(io(pn).plists.find('f2'), 10000), atest = false; end
466 if ~isequal(io(pn).plists.find('nf'), 1e3), atest = false; end
467 if ~isequal(io(pn).plists.find('scale'), 'log'), atest = false; end
468 if ~isEmptyDouble(io(pn).plists.find('f')), atest = false; end
469 if ~isequal(io(pn).plists.find('xunits'), 'Hz'), atest = false; end
470 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
471 % Check options
472 if ~isequal(io(pn).plists.getOptionsForParam('fsfcn'), {'f'}), atest = false; end
473 if ~isequal(io(pn).plists.getOptionsForParam('f1'), {1e-9}), atest = false; end
474 if ~isequal(io(pn).plists.getOptionsForParam('f2'), {1e4}), atest = false; end
475 if ~isequal(io(pn).plists.getOptionsForParam('nf'), {1e3}), atest = false; end
476 if ~isequal(io(pn).plists.getOptionsForParam('scale'), {'lin', 'log'}), atest = false; end
477 if ~isequal(io(pn).plists.getOptionsForParam('f'), {[]}), atest = false; end
478 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'Hz'}), atest = false; end
479 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
480 %%%%%%%%%% SET 'From Window'
481 pn = 17;
482 [atest, msg] = checkParamNumber(io, pn, 8);
483 % Check key
484 if ~io(pn).plists.isparam('name'), atest = false; end
485 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
486 if ~io(pn).plists.isparam('description'), atest = false; end
487 if ~io(pn).plists.isparam('win'), atest = false; end
488 if ~io(pn).plists.isparam('length'), atest = false; end
489 if ~io(pn).plists.isparam('psll'), atest = false; end
490 if ~io(pn).plists.isparam('levelorder'), atest = false; end
491 if ~io(pn).plists.isparam('yunits'), atest = false; end
492 % Check default value
493 if ~strcmpi(io(pn).plists.find('win'), char(prefs.getMiscPrefs.getDefaultWindow)), atest = false; end
494 if ~isequal(io(pn).plists.find('yunits'), ''), atest = false; end
495 % Check options
496 if ~isequal(io(pn).plists.getOptionsForParam('win'), specwin.getTypes), atest = false; end
497 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
498 %%%%%%%%%% SET 'From Waveform'
499 pn = 18;
500 [atest, msg] = checkParamNumber(io, pn, 22);
501 % Check key
502 if ~io(pn).plists.isparam('name'), atest = false; end
503 if ~io(pn).plists.isparam('description'), atest = false; end
504 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
505 if ~io(pn).plists.isparam('waveform'), atest = false; end
506 if ~io(pn).plists.isparam('a'), atest = false; end
507 if ~io(pn).plists.isparam('f'), atest = false; end
508 if ~io(pn).plists.isparam('phi'), atest = false; end
509 if ~io(pn).plists.isparam('toff'), atest = false; end
510 if ~io(pn).plists.isparam('gaps'), atest = false; end
511 if ~io(pn).plists.isparam('type'), atest = false; end
512 if ~io(pn).plists.isparam('sigma'), atest = false; end
513 if ~io(pn).plists.isparam('f0'), atest = false; end
514 if ~io(pn).plists.isparam('f1'), atest = false; end
515 if ~io(pn).plists.isparam('t1'), atest = false; end
516 if ~io(pn).plists.isparam('bw'), atest = false; end
517 if ~io(pn).plists.isparam('duty'), atest = false; end
518 if ~io(pn).plists.isparam('width'), atest = false; end
519 if ~io(pn).plists.isparam('fs'), atest = false; end
520 if ~io(pn).plists.isparam('nsecs'), atest = false; end
521 if ~io(pn).plists.isparam('t0'), atest = false; end
522 if ~io(pn).plists.isparam('xunits'), atest = false; end
523 if ~io(pn).plists.isparam('yunits'), atest = false; end
524 % Check default value
525 if ~isequal(io(pn).plists.find('waveform'), 'sine wave'), atest = false; end
526 if ~isequal(io(pn).plists.find('a'), 1), atest = false; end
527 if ~isequal(io(pn).plists.find('f'), 1), atest = false; end
528 if ~isequal(io(pn).plists.find('phi'), 0), atest = false; end
529 if ~isequal(io(pn).plists.find('toff'), 0), atest = false; end
530 if ~isEmptyDouble(io(pn).plists.find('gaps')), atest = false; end
531 if ~isequal(io(pn).plists.find('type'), 'Normal'), atest = false; end
532 if ~isequal(io(pn).plists.find('sigma'), 1), atest = false; end
533 if ~isequal(io(pn).plists.find('f0'), 1), atest = false; end
534 if ~isEmptyDouble(io(pn).plists.find('f1')), atest = false; end
535 if ~isEmptyDouble(io(pn).plists.find('t1')), atest = false; end
536 if ~isEmptyDouble(io(pn).plists.find('bw')), atest = false; end
537 if ~isequal(io(pn).plists.find('duty'), 50), atest = false; end
538 if ~isequal(io(pn).plists.find('width'), 0.5), atest = false; end
539 if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end
540 if ~isEmptyDouble(io(pn).plists.find('nsecs')), atest = false; end
541 if ~isequal(double(time(io(pn).plists.getOptionsForParam('t0'))), 0), atest = false; end
542 if ~isequal(io(pn).plists.find('xunits'), 's'), atest = false; end
543 if ~isequal(io(pn).plists.find('yunits'), ''), atest = false; end
544 % Check options
545 if ~isequal(io(pn).plists.getOptionsForParam('waveform'), {'sine wave', 'noise', 'chirp', 'gaussian pulse', 'square wave', 'sawtooth'}), atest = false; end
546 if ~isequal(io(pn).plists.getOptionsForParam('a'), {1}), atest = false; end
547 if ~isequal(io(pn).plists.getOptionsForParam('f'), {1}), atest = false; end
548 if ~isequal(io(pn).plists.getOptionsForParam('phi'), {0}), atest = false; end
549 if ~isequal(io(pn).plists.getOptionsForParam('toff'), {0}), atest = false; end
550 if ~isequal(io(pn).plists.getOptionsForParam('gaps'), {[]}), atest = false; end
551 if ~isequal(io(pn).plists.getOptionsForParam('type'), {'Normal', 'Uniform'}), atest = false; end
552 if ~isequal(io(pn).plists.getOptionsForParam('sigma'), {1}), atest = false; end
553 if ~isequal(io(pn).plists.getOptionsForParam('f0'), {1}), atest = false; end
554 if ~isequal(io(pn).plists.getOptionsForParam('f1'), {[]}), atest = false; end
555 if ~isequal(io(pn).plists.getOptionsForParam('t1'), {[]}), atest = false; end
556 if ~isequal(io(pn).plists.getOptionsForParam('bw'), {[]}), atest = false; end
557 if ~isequal(io(pn).plists.getOptionsForParam('duty'), {50}), atest = false; end
558 if ~isequal(io(pn).plists.getOptionsForParam('width'), {0.5}), atest = false; end
559 if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end
560 if ~isequal(io(pn).plists.getOptionsForParam('nsecs'), {[]}), atest = false; end
561 if ~isequal(io(pn).plists.getOptionsForParam('t0'), {'1970-01-01 00:00:00.000'}), atest = false; end
562 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'s'}), atest = false; end
563 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
564 %%%%%%%%%% SET 'From Polynomial'
565 pn = 19;
566 [atest, msg] = checkParamNumber(io, pn, 13);
567 % Check key
568 if ~io(pn).plists.isparam('name'), atest = false; end
569 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
570 if ~io(pn).plists.isparam('description'), atest = false; end
571 if ~io(pn).plists.isparam('polyval'), atest = false; end
572 if ~io(pn).plists.isparam('nsecs'), atest = false; end
573 if ~io(pn).plists.isparam('fs'), atest = false; end
574 if ~io(pn).plists.isparam('t0'), atest = false; end
575 if ~io(pn).plists.isparam('t'), atest = false; end
576 if ~io(pn).plists.isparam('x'), atest = false; end
577 if ~io(pn).plists.isparam('f'), atest = false; end
578 if ~io(pn).plists.isparam('type'), atest = false; end
579 if ~io(pn).plists.isparam('xunits'), atest = false; end
580 if ~io(pn).plists.isparam('yunits'), atest = false; end
581 % Check default value
582 if ~isEmptyDouble(io(pn).plists.find('polyval')), atest = false; end
583 if ~isEmptyDouble(io(pn).plists.find('nsecs')), atest = false; end
584 if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end
585 if ~isequal(io(pn).plists.find('t0'), '1970-01-01 00:00:00.000'), atest = false; end
586 if ~isEmptyDouble(io(pn).plists.find('t')), atest = false; end
587 if ~isEmptyDouble(io(pn).plists.find('x')), atest = false; end
588 if ~isEmptyDouble(io(pn).plists.find('f')), atest = false; end
589 if ~isequal(io(pn).plists.find('type'), 'tsdata'), atest = false; end
590 if ~isequal(io(pn).plists.find('xunits'), 's'), atest = false; end
591 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
592 % Check options
593 if ~isequal(io(pn).plists.getOptionsForParam('polyval'), {''}), atest = false; end
594 if ~isequal(io(pn).plists.getOptionsForParam('nsecs'), {[]}), atest = false; end
595 if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end
596 if ~isequal(io(pn).plists.getOptionsForParam('t0'), {'1970-01-01 00:00:00.000'}), atest = false; end
597 if ~isequal(io(pn).plists.getOptionsForParam('t'), {[]}), atest = false; end
598 if ~isequal(io(pn).plists.getOptionsForParam('x'), {[]}), atest = false; end
599 if ~isequal(io(pn).plists.getOptionsForParam('f'), {[]}), atest = false; end
600 if ~isequal(io(pn).plists.getOptionsForParam('type'), {'tsdata', 'fsdata', 'xydata', 'cdata'}), atest = false; end
601 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'s'}), atest = false; end
602 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
603 %%%%%%%%%% SET 'From Pzmodel'
604 pn = 20;
605 [atest, msg] = checkParamNumber(io, pn, 9);
606 % Check key
607 if ~io(pn).plists.isparam('name'), atest = false; end
608 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
609 if ~io(pn).plists.isparam('description'), atest = false; end
610 if ~io(pn).plists.isparam('pzmodel'), atest = false; end
611 if ~io(pn).plists.isparam('nsecs'), atest = false; end
612 if ~io(pn).plists.isparam('fs'), atest = false; end
613 if ~io(pn).plists.isparam('t0'), atest = false; end
614 if ~io(pn).plists.isparam('xunits'), atest = false; end
615 if ~io(pn).plists.isparam('yunits'), atest = false; end
616 % Check default value
617 if ~eq(io(pn).plists.find('pzmodel'), pzmodel(), ple1), atest = false; end
618 if ~isEmptyDouble(io(pn).plists.find('nsecs')), atest = false; end
619 if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end
620 if ~isequal(io(pn).plists.find('t0'), '1970-01-01 00:00:00.000'), atest = false; end
621 if ~isequal(io(pn).plists.find('xunits'), 's'), atest = false; end
622 if ~isEmptyChar(io(pn).plists.find('yunits')), atest = false; end
623 % Check options
624 if ~isequal(io(pn).plists.getOptionsForParam('nsecs'), {[]}), atest = false; end
625 if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end
626 if ~isequal(io(pn).plists.getOptionsForParam('t0'), {'1970-01-01 00:00:00.000'}), atest = false; end
627 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'s'}), atest = false; end
628 if ~isequal(io(pn).plists.getOptionsForParam('yunits'), {''}), atest = false; end
629 %%%%%%%%%% SET 'From smodel'
630 pn = 21;
631 [atest, msg] = checkParamNumber(io, pn, 7);
632 % Check key
633 if ~io(pn).plists.isparam('name'), atest = false; end
634 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
635 if ~io(pn).plists.isparam('description'), atest = false; end
636 if ~io(pn).plists.isparam('model'), atest = false; end
637 if ~io(pn).plists.isparam('xunits'), atest = false; end
638 if ~io(pn).plists.isparam('x'), atest = false; end
639 if ~io(pn).plists.isparam('type'), atest = false; end
640 % Check default value
641 if ~eq(io(pn).plists.find('model'), smodel(), ple1), atest = false; end
642 if ~isequal(io(pn).plists.find('xunits'), 's'), atest = false; end
643 if ~isEmptyDouble(io(pn).plists.find('x')), atest = false; end
644 if ~isequal(io(pn).plists.find('type'), 'tsdata'), atest = false; end
645 % Check options
646 if ~isequal(io(pn).plists.getOptionsForParam('xunits'), {'s'}), atest = false; end
647 if ~isequal(io(pn).plists.getOptionsForParam('x'), {[]}), atest = false; end
648 if ~isequal(io(pn).plists.getOptionsForParam('type'), {'tsdata', 'fsdata', 'xydata', 'cdata'}), atest = false; end
649
650 %%%%%%%%%% SET 'From pest'
651 pn = 22;
652 [atest, msg] = checkParamNumber(io, pn, 5);
653 % Check key
654 if ~io(pn).plists.isparam('name'), atest = false; end
655 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
656 if ~io(pn).plists.isparam('description'), atest = false; end
657 if ~io(pn).plists.isparam('pest'), atest = false; end
658 if ~io(pn).plists.isparam('parameter'), atest = false; end
659 % Check default value
660 if ~eq(io(pn).plists.find('pest'), []), atest = false; end
661 if ~isequal(io(pn).plists.find('parameter'), ''), atest = false; end
662 % Check options
663 if ~isequal(io(pn).plists.getOptionsForParam('pest'), {[]}), atest = false; end
664 if ~isequal(io(pn).plists.getOptionsForParam('parameter'), {''}), atest = false; end
665 %%%%%%%%%% SET 'From Parameter'
666 pn = 23;
667 [atest, msg] = checkParamNumber(io, pn, 5);
668 % Check key
669 if ~io(pn).plists.isparam('name'), atest = false; end
670 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
671 if ~io(pn).plists.isparam('description'), atest = false; end
672 if ~io(pn).plists.isparam('parameter'), atest = false; end
673 if ~io(pn).plists.isparam('key'), atest = false; end
674 % Check default value
675 if ~isEmptyChar(io(pn).plists.find('parameter')), atest = false; end
676 if ~isEmptyChar(io(pn).plists.find('key')), atest = false; end
677 % Check options
678 if ~isequal(io(pn).plists.getOptionsForParam('parameter'), {''}), atest = false; end
679 if ~isequal(io(pn).plists.getOptionsForParam('key'), {''}), atest = false; end
680 end
681 % </AlgoCode>
682 else
683 atest = false;
684 end
685
686 % Return a result structure
687 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
688 end % END UTP_01
689
690 % check parameter number
691 function [atest, msg] = checkParamNumber(sets, setNum, paramNum)
692 atest = true;
693 msg = '';
694 if sets(setNum).plists.nparams ~= paramNum
695 atest = false;
696 msg = sprintf('Set %d plist does not have %d parameters', setNum, paramNum);
697 end
698 end
699
700 %% UTP_08
701
702 % <TestDescription>
703 %
704 % Tests that the ao method properly applies history to the
705 % ASCII-file constructor.
706 %
707 % </TestDescription>
708 function result = utp_08
709
710 % <SyntaxDescription>
711 %
712 % Test that the output can be processed back to an m-file.
713 %
714 % </SyntaxDescription>
715
716 try
717 % <SyntaxCode>
718 fs = 5;
719 Nsecs = 2;
720 t = linspace(0, Nsecs-1/fs, Nsecs*fs);
721 x = randn(1,Nsecs*fs) + 2*sin(2*pi*45.*t);
722 out = [t;x].';
723
724 %---- Save data as ascii file
725 name = 'data';
726 filename1 = sprintf('%s.txt', name);
727 save(filename1, 'out', '-ASCII', '-DOUBLE', '-TABS');
728 filename2 = sprintf('%s.dat', name);
729 save(filename2, 'out', '-ASCII', '-DOUBLE', '-TABS');
730
731 out1 = ao(filename1);
732 out2 = ao(filename2);
733 mout1 = rebuild(out1);
734 mout2 = rebuild(out2);
735 % </SyntaxCode>
736 stest = true;
737 catch err
738 disp(err.message)
739 stest = false;
740 end
741
742 % <AlgoDescription>
743 %
744 % 1) Check that the last entry in the history of 'out' corresponds to
745 % 'ao'.
746 % 2) Check that the rebuilt objects are the same as 'out1' and 'ouit2'
747 %
748 % </AlgoDescription>
749
750 atest = true;
751 if stest
752 % <AlgoCode>
753 % Check the last step in the history of 'out'
754 if ~strcmp(out1.hist.methodInfo.mname, 'ao'), atest = false; end
755 if ~strcmp(out2.hist.methodInfo.mname, 'ao'), atest = false; end
756 % Check that the data-object is a cdata-object
757 if ~isa(out1.data, 'cdata'), atest = false; end
758 if ~isa(out2.data, 'cdata'), atest = false; end
759 % Check that output contains the right values
760 if ~isequal(out1.data.getY, out), atest = false; end
761 if ~isequal(out2.data.getY, out), atest = false; end
762 % Check the rebuilt object
763 if ~eq(mout1, out1, ple1), atest = false; end
764 if ~eq(mout2, out2, ple1), atest = false; end
765 % </AlgoCode>
766 % delete test file
767 delete(filename1);
768 delete(filename2);
769 else
770 atest = false;
771 end
772
773 % Return a result structure
774 result = utp_prepare_result(atest, stest, dbstack, mfilename);
775 end % END UTP_08
776
777
778 %% UTP_09
779
780 % <TestDescription>
781 %
782 % Tests that the ao method properly applies history to the complex
783 % ASCII-file constructor.
784 %
785 % </TestDescription>
786 function result = utp_09
787
788 % <SyntaxDescription>
789 %
790 % Test that the output can be processed back to an m-file.
791 %
792 % </SyntaxDescription>
793
794 try
795 % <SyntaxCode>
796 a1 = ao(1:123, randn(123,1)+randn(123,1)*1i, plist('type', 'fsdata'));
797 filename1 = 'complex1.txt';
798 filename2 = 'complex2.txt';
799 filename3 = 'complex3.txt';
800 filename4 = 'complex4.txt';
801 filename5 = 'complex5.txt';
802
803 %---- Save: f, real, imag
804 export1 = [a1.x real(a1.y) imag(a1.y)];
805 save(filename1, 'export1', '-ASCII', '-DOUBLE', '-TABS');
806 %---- Save: f, abs, deg
807 export2 = [a1.x abs(a1.y) (180/pi) * (angle(a1.y))];
808 save(filename2, 'export2', '-ASCII', '-DOUBLE', '-TABS');
809 %---- Save: f, abs, rad
810 export3 = [a1.x abs(a1.y) angle(a1.y)];
811 save(filename3, 'export3', '-ASCII', '-DOUBLE', '-TABS');
812 %---- Save: f, dB, deg
813 export4 = [a1.x 20.*log10(abs(a1.y)) (180/pi) * (angle(a1.y))];
814 save(filename4, 'export4', '-ASCII', '-DOUBLE', '-TABS');
815 %---- Save: f, dB, rad
816 export5 = [a1.x angle(a1.y) 20.*log10(abs(a1.y)) angle(a1.y) 20.*log10(abs(a1.y)) angle(a1.y) 20.*log10(abs(a1.y))];
817 save(filename5, 'export5', '-ASCII', '-DOUBLE', '-TABS');
818
819 out1 = ao(filename1, plist('complex_type', 'real/imag'));
820 out2 = ao(filename2, plist('complex_type', 'abs/deg'));
821 out3 = ao(filename3, plist('complex_type', 'abs/rad'));
822 out4 = ao(filename4, plist('complex_type', 'dB/deg'));
823 out5 = ao(filename5, plist('complex_type', 'dB/rad', 'columns', [1 7 4]));
824
825 mout1 = rebuild(out1);
826 mout2 = rebuild(out2);
827 mout3 = rebuild(out3);
828 mout4 = rebuild(out4);
829 mout5 = rebuild(out5);
830 % </SyntaxCode>
831 stest = true;
832 catch err
833 disp(err.message)
834 stest = false;
835 end
836
837 % <AlgoDescription>
838 %
839 % 1) Check that the last entry in the history of 'out' corresponds to
840 % 'ao'.
841 % 2) Check that the read data are correct
842 % 3) Check that the rebuilt object is the same as in 'out1..5'
843 %
844 % </AlgoDescription>
845
846 atest = true;
847 TOL = 1e-14;
848 if stest
849 % <AlgoCode>
850 % Check the last step in the history of 'out'
851 if ~strcmp(out1.hist.methodInfo.mname, 'ao'), atest = false; end
852 if ~strcmp(out2.hist.methodInfo.mname, 'ao'), atest = false; end
853 if ~strcmp(out3.hist.methodInfo.mname, 'ao'), atest = false; end
854 if ~strcmp(out4.hist.methodInfo.mname, 'ao'), atest = false; end
855 if ~strcmp(out5.hist.methodInfo.mname, 'ao'), atest = false; end
856 % Check that output contains the correct values
857 % 'out1' -> f, real, imag
858 if ~isequal(out1.x, a1.x), atest = false; end
859 if any(abs(out1.y - a1.y) > TOL), atest = false; end
860 % 'out2' -> f, abs, deg
861 if ~isequal(out2.x, a1.x), atest = false; end
862 if any(abs(out2.y - a1.y) > TOL), atest = false; end
863 % 'out3' -> f, abs, rad
864 if ~isequal(out3.x, a1.x), atest = false; end
865 if any(abs(out3.y - a1.y) > TOL), atest = false; end
866 % 'out4' -> f, dB, deg
867 if ~isequal(out4.x, a1.x), atest = false; end
868 if any(abs(out4.y - a1.y) > TOL), atest = false; end
869 % 'out5' -> f, dB, rad
870 if ~isequal(out5.x, a1.x), atest = false; end
871 if any(abs(out5.y - a1.y) > TOL), atest = false; end
872 % Check the re-built objects
873 if ~eq(mout1, out1, ple2), atest = false; end
874 if ~eq(mout2, out2, ple2), atest = false; end
875 if ~eq(mout3, out3, ple2), atest = false; end
876 if ~eq(mout4, out4, ple2), atest = false; end
877 if ~eq(mout5, out5, ple2), atest = false; end
878 % </AlgoCode>
879 % delete test file
880 delete(filename1);
881 delete(filename2);
882 delete(filename3);
883 delete(filename4);
884 delete(filename5);
885 else
886 atest = false;
887 end
888
889 % Return a result structure
890 result = utp_prepare_result(atest, stest, dbstack, mfilename);
891 end % END UTP_09
892
893 %% UTP_13
894
895 % <TestDescription>
896 %
897 % Tests that the ao method properly applies history to the vals constructor.
898 %
899 % </TestDescription>
900 function result = utp_13
901
902 % <SyntaxDescription>
903 %
904 % Test that the output can be processed back to an m-file.
905 %
906 % </SyntaxDescription>
907
908 try
909 % <SyntaxCode>
910 vals = [1 2 3 4 5; 1 2 3 4 5];
911 out = ao(vals);
912 mout = rebuild(out);
913 % </SyntaxCode>
914 stest = true;
915 catch err
916 disp(err.message)
917 stest = false;
918 end
919
920 % <AlgoDescription>
921 %
922 % 1) Check that the last entry in the history of 'out' corresponds to
923 % 'ao'.
924 % 2) Check that the rebuilt object is the same as 'out'.
925 %
926 % </AlgoDescription>
927
928 atest = true;
929 if stest
930 % <AlgoCode>
931 % Check the last step in the history of 'out'
932 if ~strcmp(out.hist.methodInfo.mname, 'ao'), atest = false; end
933 % Check the rebuilt object
934 if ~eq(mout, out, ple1), atest = false; end
935 % </AlgoCode>
936 else
937 atest = false;
938 end
939
940 % Return a result structure
941 result = utp_prepare_result(atest, stest, dbstack, mfilename);
942 end % END UTP_13
943
944 %% UTP_15
945
946 % <TestDescription>
947 %
948 % Tests that the ao method properly applies history to the plist(fcn) constructor.
949 %
950 % </TestDescription>
951 function result = utp_15
952
953 % <SyntaxDescription>
954 %
955 % Test that the output can be processed back to an m-file.
956 %
957 % </SyntaxDescription>
958
959 try
960 % <SyntaxCode>
961 fcn = 'complex(randn(100,1), randn(100,1))';
962 out = ao(plist('fcn', fcn));
963 mout = rebuild(out);
964 % </SyntaxCode>
965 stest = true;
966 catch err
967 disp(err.message)
968 stest = false;
969 end
970
971 % <AlgoDescription>
972 %
973 % 1) Check that the last entry in the history of 'out' corresponds to
974 % 'ao'.
975 % 2) Check that the rebuilt object is the same as 'out'.
976 %
977 % </AlgoDescription>
978
979 atest = true;
980 if stest
981 % <AlgoCode>
982 % Check the last step in the history of 'out'
983 if ~strcmp(out.hist.methodInfo.mname, 'ao'), atest = false; end
984 % Check values of the AO
985 if isreal(out.data.getY), atest = false; end
986 % Check the rebuilt object
987 if ~eq(mout, out, ple1), atest = false; end
988 % </AlgoCode>
989 else
990 atest = false;
991 end
992
993 % Return a result structure
994 result = utp_prepare_result(atest, stest, dbstack, mfilename);
995 end % END UTP_15
996
997
998 %% UTP_16
999
1000 % <TestDescription>
1001 %
1002 % Tests that the ao method properly applies history to the plist(vals) constructor.
1003 %
1004 % </TestDescription>
1005 function result = utp_16
1006
1007 % <SyntaxDescription>
1008 %
1009 % Test that the output can be processed back to an m-file.
1010 %
1011 % </SyntaxDescription>
1012
1013 try
1014 % <SyntaxCode>
1015 vals = [1 2 3 4 5; 6 7 8 9 0];
1016 out = ao(plist('vals', vals));
1017 mout = rebuild(out);
1018 % </SyntaxCode>
1019 stest = true;
1020 catch err
1021 disp(err.message)
1022 stest = false;
1023 end
1024
1025 % <AlgoDescription>
1026 %
1027 % 1) Check that the last entry in the history of 'out' corresponds to
1028 % 'ao'.
1029 % 2) Check that the rebuilt object is the same as 'out'.
1030 %
1031 % </AlgoDescription>
1032
1033 atest = true;
1034 if stest
1035 % <AlgoCode>
1036 % Check the last step in the history of 'out'
1037 if ~strcmp(out.hist.methodInfo.mname, 'ao'), atest = false; end
1038 % Check values of the AO
1039 if ~eq(out.data.getY, vals), atest = false; end
1040 % Check the rebuilt object
1041 if ~eq(mout, out, ple1), atest = false; end
1042 % </AlgoCode>
1043 else
1044 atest = false;
1045 end
1046
1047 % Return a result structure
1048 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1049 end % END UTP_16
1050
1051
1052 %% UTP_17
1053
1054 % <TestDescription>
1055 %
1056 % Tests that the ao method properly applies history to the plist(x/y-vals) constructor.
1057 %
1058 % </TestDescription>
1059 function result = utp_17
1060
1061 % <SyntaxDescription>
1062 %
1063 % Test that the output can be processed back to an m-file.
1064 %
1065 % </SyntaxDescription>
1066
1067 try
1068 % <SyntaxCode>
1069 xvals = 0:99;
1070 yvals = randn(100,1);
1071 out = ao(plist('xvals', xvals, 'yvals', yvals));
1072 mout = rebuild(out);
1073 % </SyntaxCode>
1074 stest = true;
1075 catch err
1076 disp(err.message)
1077 stest = false;
1078 end
1079
1080 % <AlgoDescription>
1081 %
1082 % 1) Check that the last entry in the history of 'out' corresponds to
1083 % 'ao'.
1084 % 2) Check that the rebuilt object is the same as 'out'.
1085 %
1086 % </AlgoDescription>
1087
1088 atest = true;
1089 if stest
1090 % <AlgoCode>
1091 % Check the last step in the history of 'out'
1092 if ~strcmp(out.hist.methodInfo.mname, 'ao'), atest = false; end
1093 % Check values of the AO
1094 if ~eq(out.data.getX, xvals'), atest = false; end
1095 if ~eq(out.data.getY, yvals), atest = false; end
1096 % Check the rebuilt object
1097 if ~eq(mout, out, ple1), atest = false; end
1098 % </AlgoCode>
1099 else
1100 atest = false;
1101 end
1102
1103 % Return a result structure
1104 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1105 end % END UTP_17
1106
1107
1108 %% UTP_18
1109
1110 % <TestDescription>
1111 %
1112 % Tests that the ao method properly applies history to the plist(tsfcn) constructor.
1113 %
1114 % </TestDescription>
1115 function result = utp_18
1116
1117 % <SyntaxDescription>
1118 %
1119 % Test that the output can be processed back to an m-file.
1120 %
1121 % </SyntaxDescription>
1122
1123 try
1124 % <SyntaxCode>
1125 tsfcn = 'sin(2*pi*7.433*t) + randn(size(t))';
1126 out = ao(plist('tsfcn', tsfcn, 'nsecs', 10, 'fs', 12.3));
1127 mout = rebuild(out);
1128 % </SyntaxCode>
1129 stest = true;
1130 catch err
1131 disp(err.message)
1132 stest = false;
1133 end
1134
1135 % <AlgoDescription>
1136 %
1137 % 1) Check that the last entry in the history of 'out' corresponds to
1138 % 'ao'.
1139 % 2) Check that the rebuilt object is the same as 'out'.
1140 %
1141 % </AlgoDescription>
1142
1143 atest = true;
1144 if stest
1145 % <AlgoCode>
1146 % Check the last step in the history of 'out'
1147 if ~strcmp(out.hist.methodInfo.mname, 'ao'), atest = false; end
1148 % Check the rebuilt object
1149 if ~eq(mout, out, ple1), atest = false; end
1150 % </AlgoCode>
1151 else
1152 atest = false;
1153 end
1154
1155 % Return a result structure
1156 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1157 end % END UTP_18
1158
1159
1160 %% UTP_19
1161
1162 % <TestDescription>
1163 %
1164 % Tests that the ao method properly applies history to the plist(fsfcn) constructor.
1165 %
1166 % </TestDescription>
1167 function result = utp_19
1168
1169 % <SyntaxDescription>
1170 %
1171 % Test that the output can be processed back to an m-file.
1172 %
1173 % </SyntaxDescription>
1174
1175 try
1176 % <SyntaxCode>
1177 fsfcn1 = '1e-15.*(1e-3./f.^2 + 1e-10./f.^4)';
1178 fsfcn2 = '1./f.^2';
1179 out1 = ao(plist('fsfcn', fsfcn1, 'nf', 100));
1180 out2 = ao(plist('fsfcn', fsfcn2, 'nf', 100, 'scale', 'lin'));
1181 mout1 = rebuild(out1);
1182 mout2 = rebuild(out2);
1183 % </SyntaxCode>
1184 stest = true;
1185 catch err
1186 disp(err.message)
1187 stest = false;
1188 end
1189
1190 % <AlgoDescription>
1191 %
1192 % 1) Check that the last entry in the history of 'out' corresponds to
1193 % 'ao'.
1194 % 2) Check that the rebuilt objects are the same as 'out1' and 'out2'
1195 %
1196 % </AlgoDescription>
1197
1198 atest = true;
1199 if stest
1200 % <AlgoCode>
1201 % Check the last step in the history of 'out'
1202 if ~strcmp(out1.hist.methodInfo.mname, 'ao'), atest = false; end
1203 if ~strcmp(out2.hist.methodInfo.mname, 'ao'), atest = false; end
1204 % Check the rebuilt object
1205 if ~eq(mout1, out1, ple1), atest = false; end
1206 if ~eq(mout2, out2, ple1), atest = false; end
1207 % </AlgoCode>
1208 else
1209 atest = false;
1210 end
1211
1212 % Return a result structure
1213 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1214 end % END UTP_19
1215
1216
1217 %% UTP_20
1218
1219 % <TestDescription>
1220 %
1221 % Tests that the ao method properly applies history to the plist(win) constructor.
1222 %
1223 % </TestDescription>
1224 function result = utp_20
1225
1226 % <SyntaxDescription>
1227 %
1228 % Test that the output can be processed back to an m-file.
1229 %
1230 % </SyntaxDescription>
1231
1232 msg = '';
1233 try
1234 % <SyntaxCode>
1235 win = specwin('Hamming', 10);
1236 out1 = ao(plist('win', win));
1237 mout1 = rebuild(out1);
1238 out2 = ao(plist('win', 'Kaiser', 'length', 53, 'psll', 75));
1239 mout2 = rebuild(out2);
1240 % </SyntaxCode>
1241 stest = true;
1242 catch err
1243 disp(err.message)
1244 msg = err.message;
1245 stest = false;
1246 end
1247
1248 % <AlgoDescription>
1249 %
1250 % 1) Check that the last entry in the history of 'out' corresponds to 'ao'.
1251 % 2) Check that the rebuilt object is the same as 'out'.
1252 %
1253 % </AlgoDescription>
1254
1255 atest = true;
1256 if stest
1257 % <AlgoCode>
1258 % Check the last step in the history of 'out'
1259 if ~strcmp(out1.hist.methodInfo.mname, 'ao'), atest = false; msg = 'last history step is not an ao constructor'; end
1260 if ~strcmp(out2.hist.methodInfo.mname, 'ao'), atest = false; msg = 'last history step is not an ao constructor'; end
1261 % Check data values
1262 if ~isequal(win.win.', out1.data.getY), atest = false; msg = 'Window values are different when rebuilt'; end
1263 % Check the rebuilt object
1264 if ~eq(mout1, out1, ple1), atest = false; msg = '1st rebuilt object is different'; end
1265 if ~eq(mout2, out2, ple1), atest = false; msg = '2nd rebuilt object is different'; end
1266 % </AlgoCode>
1267 else
1268 atest = false;
1269 end
1270
1271 % Return a result structure
1272 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
1273 end % END UTP_20
1274
1275
1276 %% UTP_21
1277
1278 % <TestDescription>
1279 %
1280 % Tests that the ao method properly applies history to the plist(waveform) constructor.
1281 %
1282 % </TestDescription>
1283 function result = utp_21
1284
1285 % <SyntaxDescription>
1286 %
1287 % Test that the output can be processed back to an m-file.
1288 %
1289 % </SyntaxDescription>
1290
1291 try
1292 % <SyntaxCode>
1293 nsecs = 10;
1294 fs = 10;
1295 % Sine wave
1296 pl_sin = plist('nsecs', nsecs, 'fs', fs, 'waveform', 'sine wave' , 'phi', 30, 'f', 1.23);
1297 % Noise normal
1298 pl_noise_norm = plist('nsecs', nsecs, 'fs', fs, 'waveform', 'noise' , 'type', 'Normal');
1299 % Noise uniform
1300 pl_noise_uni = plist('nsecs', nsecs, 'fs', fs, 'waveform', 'noise' , 'type', 'Uniform');
1301 % Chirp
1302 pl_chirp = plist('nsecs', nsecs, 'fs', fs, 'waveform', 'chirp' , 'f0', 1, 'f1', 50, 't1', 100);
1303 % Gaussian pulse
1304 pl_gauss = plist('nsecs', nsecs, 'fs', fs, 'waveform', 'Gaussian pulse' , 'f0', 10, 'bw', 100);
1305 % Square wave
1306 pl_square = plist('nsecs', nsecs, 'fs', fs, 'waveform', 'Square wave' , 'f', 1, 'duty', 50);
1307 % Sawtooth
1308 pl_saw = plist('nsecs', nsecs, 'fs', fs, 'waveform', 'Sawtooth' , 'width', 0.5, 'f', 1);
1309 out_sin = ao(pl_sin);
1310 out_nn = ao(pl_noise_norm);
1311 out_nu = ao(pl_noise_uni);
1312 out_chirp = ao(pl_chirp);
1313 out_gauss = ao(pl_gauss);
1314 out_square = ao(pl_square);
1315 out_saw = ao(pl_saw);
1316
1317 mout_sin = rebuild(out_sin);
1318 mout_nn = rebuild(out_nn);
1319 mout_nu = rebuild(out_nu);
1320 mout_chirp = rebuild(out_chirp);
1321 mout_gauss = rebuild(out_gauss);
1322 mout_square = rebuild(out_square);
1323 mout_saw = rebuild(out_saw);
1324 % </SyntaxCode>
1325 stest = true;
1326 catch err
1327 disp(err.message)
1328 stest = false;
1329 end
1330
1331 % <AlgoDescription>
1332 %
1333 % 1) Check that the last entry in the history of 'out' corresponds to
1334 % 'ao'.
1335 % 2) Check that the rebuilt objects are the same as 'out_...'.
1336 %
1337 % </AlgoDescription>
1338
1339 atest = true;
1340 if stest
1341 % <AlgoCode>
1342 % Check the last step in the history of 'out'
1343 if ~strcmp(out_sin.hist.methodInfo.mname, 'ao'), atest = false; end
1344 if ~strcmp(out_nn.hist.methodInfo.mname, 'ao'), atest = false; end
1345 if ~strcmp(out_nu.hist.methodInfo.mname, 'ao'), atest = false; end
1346 if ~strcmp(out_chirp.hist.methodInfo.mname, 'ao'), atest = false; end
1347 if ~strcmp(out_gauss.hist.methodInfo.mname, 'ao'), atest = false; end
1348 if ~strcmp(out_square.hist.methodInfo.mname, 'ao'), atest = false; end
1349 if ~strcmp(out_saw.hist.methodInfo.mname, 'ao'), atest = false; end
1350 % Check the rebuilt object
1351 if ~eq(mout_sin, out_sin, ple1), atest = false; end
1352 if ~eq(mout_nn, out_nn, ple1), atest = false; end
1353 if ~eq(mout_nu, out_nu, ple1), atest = false; end
1354 if ~eq(mout_chirp, out_chirp, ple1), atest = false; end
1355 if ~eq(mout_gauss, out_gauss, ple1), atest = false; end
1356 if ~eq(mout_square, out_square, ple1), atest = false; end
1357 if ~eq(mout_saw, out_saw, ple1), atest = false; end
1358 % </AlgoCode>
1359 else
1360 atest = false;
1361 end
1362
1363 % Return a result structure
1364 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1365 end % END UTP_21
1366
1367
1368
1369 %% UTP_23
1370
1371 % <TestDescription>
1372 %
1373 % Tests that the ao method properly applies history to the plist(polynomial) constructor.
1374 %
1375 % </TestDescription>
1376 function result = utp_23
1377
1378 % <SyntaxDescription>
1379 %
1380 % Test that the output can be processed back to an m-file.
1381 %
1382 % </SyntaxDescription>
1383
1384 try
1385 % <SyntaxCode>
1386 fs = 10;
1387 Nsecs = 20;
1388 coeffs = ao([2 0 1]);
1389 out1 = ao(plist('polyval', coeffs, 'fs', fs, 'Nsecs', Nsecs));
1390 out2 = ao(plist('polyval', coeffs.y, 'fs', fs, 'Nsecs', Nsecs));
1391 mout1 = rebuild(out1);
1392 mout2 = rebuild(out2);
1393 % </SyntaxCode>
1394 stest = true;
1395 catch err
1396 disp(err.message)
1397 stest = false;
1398 end
1399
1400 % <AlgoDescription>
1401 %
1402 % 1) Check that the last entry in the history of 'out' corresponds to
1403 % 'ao'.
1404 % 2) Check that the rebuilt object is the same as 'out'.
1405 %
1406 % </AlgoDescription>
1407
1408 atest = true;
1409 if stest
1410 % <AlgoCode>
1411 % Check the last step in the history of 'out'
1412 if ~strcmp(out1.hist.methodInfo.mname, 'ao'), atest = false; end
1413 if ~strcmp(out2.hist.methodInfo.mname, 'ao'), atest = false; end
1414 % Check data values
1415 t = [0 : 1/fs : Nsecs-1/fs].';
1416 y = polyval(coeffs.y,t);
1417 if ~isequal(out1.data.getY, y), atest = false; end
1418 if ~isequal(out2.data.getY, y), atest = false; end
1419 if ~isequal(out1.data.getX, t), atest = false; end
1420 if ~isequal(out2.data.getX, t), atest = false; end
1421 % Check the rebuilt object
1422 if ~eq(mout1, out1, ple1), atest = false; end
1423 if ~eq(mout2, out2, ple1), atest = false; end
1424 % </AlgoCode>
1425 else
1426 atest = false;
1427 end
1428
1429 % Return a result structure
1430 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1431 end % END UTP_23
1432
1433
1434 %% UTP_25
1435
1436 % <TestDescription>
1437 %
1438 % Tests that the ao method properly applies history to the plist(specwin) constructor.
1439 % Tests that the ao method properly uses the specwin values.
1440 %
1441 % </TestDescription>
1442 function result = utp_25
1443
1444 % <SyntaxDescription>
1445 %
1446 % Test that the output can be processed back to an m-file.
1447 %
1448 % </SyntaxDescription>
1449
1450 stest = true;
1451 atest = true;
1452 msg = '';
1453
1454 % Test Kaiser window
1455 try
1456 % <SyntaxCode>
1457 win = specwin('kaiser', randi(1000, 1), 10);
1458 out = ao(win);
1459 mout = rebuild(out);
1460 % </SyntaxCode>
1461 catch err
1462 disp(err.message)
1463 msg = err.message;
1464 stest = false;
1465 end
1466
1467 % <AlgoDescription>
1468 %
1469 % 1) Check that the last entry in the history of 'out' corresponds to
1470 % 'ao'.
1471 % 2) Check that the object contains the same data as the window.
1472 % 3) Check that the rebuilt object is the same as 'out'.
1473 %
1474 % </AlgoDescription>
1475
1476 if stest
1477 % <AlgoCode>
1478 % Check the last step in the history of 'out'
1479 if ~strcmp(out.hist.methodInfo.mname, 'ao'), msg = 'last history step is not the ao constructor'; atest = false; end
1480 % Check data values
1481 if ~isequal(win.win', out.data.getY), msg = 'window values are different in the resulting ao'; atest = false; end
1482 % Check the rebuilt object
1483 if ~eq(mout, out, ple1), msg = ['the rebuilt object is not the same as the original: ' lastwarn]; atest = false; end
1484 % </AlgoCode>
1485 else
1486 atest = false;
1487 end
1488
1489 win_list = specwin.getTypes;
1490
1491 % Test standard windows
1492 for kk = 1:numel(win_list)-2
1493 try
1494 % <SyntaxCode>
1495 win = specwin(win_list{kk}, randi(1000, 1));
1496 out = ao(win);
1497 mout = rebuild(out);
1498 % </SyntaxCode>
1499
1500 catch err
1501 disp(err.message)
1502 msg = err.message;
1503 stest = false;
1504 end
1505
1506 % <AlgoDescription>
1507 %
1508 % 1) Check that the last entry in the history of 'out' corresponds to
1509 % 'ao'.
1510 % 2) Check that the object contains the same data as the window.
1511 % 3) Check that the rebuilt object is the same as 'out'.
1512 %
1513 % </AlgoDescription>
1514
1515 if stest
1516 % <AlgoCode>
1517 % Check the last step in the history of 'out'
1518 if ~strcmp(out.hist.methodInfo.mname, 'ao'), msg = 'last history step is not the ao constructor'; atest = false; end
1519 % Check data values
1520 if ~isequal(win.win', out.data.getY), msg = 'window values are different in the resulting ao'; atest = false; end
1521 % Check the rebuilt object
1522 if ~eq(mout, out, ple1), msg = ['the rebuilt object is not the same as the original: ' lastwarn]; atest = false; end
1523 % </AlgoCode>
1524 else
1525 atest = false;
1526 end
1527
1528 end
1529
1530 % Return a result structure
1531 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
1532 end % END UTP_25
1533
1534
1535 %% UTP_26
1536
1537 % <TestDescription>
1538 %
1539 % Tests that the ao method properly applies history to the data-object constructor.
1540 %
1541 % </TestDescription>
1542 function result = utp_26
1543
1544 % <SyntaxDescription>
1545 %
1546 % Test that the output can be processed back to an m-file.
1547 %
1548 % </SyntaxDescription>
1549
1550 try
1551 % <SyntaxCode>
1552 y = randn(100,1);
1553 m = randn(3,2);
1554
1555 out1 = ao(cdata(m));
1556 out2 = ao(fsdata(y));
1557 out3 = ao(tsdata(y));
1558 out4 = ao(xydata(y));
1559 out5 = ao(xyzdata);
1560 % </SyntaxCode>
1561 stest = true;
1562 catch err
1563 disp(err.message)
1564 stest = false;
1565 end
1566
1567 % <AlgoDescription>
1568 %
1569 % 1) Check that the last entry in the history of 'out' corresponds to
1570 % 'ao'.
1571 %
1572 % </AlgoDescription>
1573
1574 atest = true;
1575 if stest
1576 % <AlgoCode>
1577 % Check the last step in the history of 'out'
1578 if ~strcmp(out1.hist.methodInfo.mname, 'ao'), atest = false; end
1579 if ~strcmp(out2.hist.methodInfo.mname, 'ao'), atest = false; end
1580 if ~strcmp(out3.hist.methodInfo.mname, 'ao'), atest = false; end
1581 if ~strcmp(out4.hist.methodInfo.mname, 'ao'), atest = false; end
1582 if ~strcmp(out5.hist.methodInfo.mname, 'ao'), atest = false; end
1583 % Check data values
1584 if ~isa(out1.data, 'cdata'), atest = false; end
1585 if ~isa(out2.data, 'fsdata'), atest = false; end
1586 if ~isa(out3.data, 'tsdata'), atest = false; end
1587 if ~isa(out4.data, 'xydata'), atest = false; end
1588 if ~isa(out5.data, 'xyzdata'), atest = false; end
1589 if ~eq(out1.data.getY, m), atest = false; end
1590 if ~eq(out2.data.getY, y), atest = false; end
1591 if ~eq(out3.data.getY, y), atest = false; end
1592 if ~eq(out4.data.getY, y), atest = false; end
1593 % </AlgoCode>
1594 else
1595 atest = false;
1596 end
1597
1598 % Return a result structure
1599 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1600 end % END UTP_26
1601
1602 %% UTP_28
1603
1604 % <TestDescription>
1605 %
1606 % Tests that the ao method properly applies history to the x-vector, y-vector constructor.
1607 %
1608 % </TestDescription>
1609 function result = utp_28
1610
1611 % <SyntaxDescription>
1612 %
1613 % Test that the output can be processed back to an m-file.
1614 %
1615 % </SyntaxDescription>
1616
1617 try
1618 % <SyntaxCode>
1619 x = 0:99;
1620 y = randn(100,1);
1621
1622 out = ao(x, y);
1623 mout = rebuild(out);
1624 % </SyntaxCode>
1625 stest = true;
1626 catch err
1627 disp(err.message)
1628 stest = false;
1629 end
1630
1631 % <AlgoDescription>
1632 %
1633 % 1) Check that the last entry in the history of 'out' corresponds to
1634 % 'ao'.
1635 % 2) Check that the rebuilt object is the same as 'out'.
1636 %
1637 % </AlgoDescription>
1638
1639 atest = true;
1640 if stest
1641 % <AlgoCode>
1642 % Check the last step in the history of 'out'
1643 if ~strcmp(out.hist.methodInfo.mname, 'ao'), atest = false; end
1644 % Check data values
1645 if ~eq(out.data.getX, x'), atest = false; end
1646 if ~eq(out.data.getY, y), atest = false; end
1647 % Check the rebuilt object
1648 if ~eq(mout, out, ple1), atest = false; end
1649 % </AlgoCode>
1650 else
1651 atest = false;
1652 end
1653
1654 % Return a result structure
1655 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1656 end % END UTP_28
1657
1658
1659 %% UTP_29
1660
1661 % <TestDescription>
1662 %
1663 % Tests that the ao method properly applies history to the filename +
1664 % plist constructor.
1665 %
1666 % </TestDescription>
1667 function result = utp_29
1668
1669 % <SyntaxDescription>
1670 %
1671 % Test that the output can be processed back to an m-file.
1672 %
1673 % </SyntaxDescription>
1674
1675 try
1676 % <SyntaxCode>
1677 %---- Make test file
1678 fs = 10;
1679 Nsecs = 10;
1680 t = linspace(0, Nsecs-1/fs, Nsecs*fs);
1681 x1 = randn(1,Nsecs*fs) + 2*sin(2*pi*45.*t);
1682 x2 = randn(1,Nsecs*fs) + 2*sin(2*pi*45.*t);
1683
1684 %---- Save data as ascii file
1685 filename = 'data.txt';
1686 fd = fopen(filename, 'w+');
1687 % write header
1688 fprintf(fd, '// A comment that should be read appropriately.\n');
1689 fprintf(fd, '// \n');
1690 fprintf(fd, '// M Hewitson\n');
1691 % write data
1692 for j=1:length(t)
1693 fprintf(fd, '%.17g\t%.17g\t%.17g\n', t(j), x1(j), x2(j));
1694 end
1695 % close file
1696 fclose(fd);
1697
1698 desc = 'ao from filename';
1699 xunits = 's';
1700 yunits = 'V';
1701
1702 pl = plist(...
1703 'description', desc,...
1704 'type', 'tsdata', ...
1705 'xunits', xunits, ...
1706 'yunits', yunits, ...
1707 'columns', [1 2 1 3], ...
1708 'comment_char', '//');
1709
1710 out = ao(filename, pl);
1711 mout = rebuild(out);
1712 % </SyntaxCode>
1713 stest = true;
1714 catch err
1715 disp(err.message)
1716 stest = false;
1717 end
1718
1719 % <AlgoDescription>
1720 %
1721 % 1) Check that the last entry in the history of 'out' corresponds to
1722 % 'ao'.
1723 % 2) Check that the rebuilt object is the same as 'out'.
1724 %
1725 % </AlgoDescription>
1726
1727 atest = true;
1728 if stest
1729 % <AlgoCode>
1730 % Check the last step in the history of 'out'
1731 if ~strcmp(out(1).hist.methodInfo.mname, 'ao'), atest = false; end
1732 if ~strcmp(out(2).hist.methodInfo.mname, 'ao'), atest = false; end
1733 % Check data values
1734 if ~isa(out(1).data, 'tsdata'), atest = false; end
1735 if ~isa(out(2).data, 'tsdata'), atest = false; end
1736 if any(abs(out(1).data.getX - t.') > TOL), atest = false; end
1737 if ~isequal(out(1).data.getY, x1.'), atest = false; end
1738 if any(abs(out(2).data.getX - t.') > TOL), atest = false; end
1739 if ~isequal(out(2).data.getY, x2.'), atest = false; end
1740 % Check the rebuilt object
1741 if ~eq(mout, out, ple1), atest = false; end
1742 % </AlgoCode>
1743 delete(filename);
1744 else
1745 atest = false;
1746 end
1747
1748 % Return a result structure
1749 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1750 end % END UTP_29
1751
1752
1753 %% UTP_30
1754
1755 % <TestDescription>
1756 %
1757 % Tests that the ao method properly applies history to the filename +
1758 % plist constructor.
1759 %
1760 % </TestDescription>
1761 function result = utp_30
1762
1763 % <SyntaxDescription>
1764 %
1765 % Test that the output can be processed back to an m-file.
1766 %
1767 % </SyntaxDescription>
1768
1769 try
1770 % <SyntaxCode>
1771 %---- Make test file
1772 fs = 10;
1773 Nsecs = 10;
1774 t = linspace(0, Nsecs-1/fs, Nsecs*fs);
1775 x1 = .1*randn(1,Nsecs*fs) + 2*sin(2*pi*45.*t) + randn(1,Nsecs*fs)*1i;
1776 x2 = .1*randn(1,Nsecs*fs) + 2*sin(2*pi*45.*t) + randn(1,Nsecs*fs)*1i;
1777
1778 %---- Save data as ascii file
1779 filename = 'complex.txt';
1780 fd = fopen(filename, 'w+');
1781 % write header
1782 fprintf(fd, '// A comment that should be read appropriately.\n');
1783 fprintf(fd, '// \n');
1784 fprintf(fd, '// M Hewitson\n');
1785 % write data
1786 for j=1:length(t)
1787
1788 %---- Save: f, abs, rad, abs, rad
1789 fprintf(fd, '%.17g\t%.17g\t%.17g\t%.17g\t%.17g\n', t(j), abs(x1(j)), angle(x1(j)), abs(x2(j)), angle(x2(j)));
1790 end
1791 % close file
1792 fclose(fd);
1793
1794 desc = 'ao from complex data';
1795 xunits = 'Hz';
1796 yunits = 'V';
1797
1798 pl = plist(...
1799 'complex_type', 'abs/rad', ...
1800 'columns', [1 2 3 1 4 5], ...
1801 'type', 'xydata', ...
1802 'description', desc,...
1803 'xunits', xunits, ...
1804 'yunits', yunits, ...
1805 'comment_char', '//');
1806
1807 out = ao(filename, pl);
1808 mout = rebuild(out);
1809 % </SyntaxCode>
1810 stest = true;
1811 catch err
1812 disp(err.message)
1813 stest = false;
1814 end
1815
1816 % <AlgoDescription>
1817 %
1818 % 1) Check that the last entry in the history of 'out' corresponds to
1819 % 'ao'.
1820 % 2) Check the read data
1821 % 3) Check that the rebuilt object is the same as 'out'
1822 %
1823 % </AlgoDescription>
1824
1825 atest = true;
1826 if stest
1827 % <AlgoCode>
1828 % Check the last step in the history of 'out'
1829 if ~strcmp(out(1).hist.methodInfo.mname, 'ao'), atest = false; end
1830 if ~strcmp(out(2).hist.methodInfo.mname, 'ao'), atest = false; end
1831 % Check data values
1832 if ~isa(out(1).data, 'xydata'), atest = false; end
1833 if ~isa(out(2).data, 'xydata'), atest = false; end
1834 % 'out(1)' -> f, abs, rad
1835 if ~isequal(out(1).x, t.'), atest = false; end
1836 if any(abs(out(1).y - x1.') > TOL), atest = false; end
1837 if ~eq(out(1).yunits, unit(yunits)), atest = false; end
1838 if ~eq(out(1).xunits, unit(xunits)), atest = false; end
1839 if ~strcmp(out(1).description, desc), atest = false; end
1840 % 'out(2)' -> f, abs, rad
1841 if ~isequal(out(2).x, t.'), atest = false; end
1842 if any(abs(out(2).y - x2.') > TOL), atest = false; end
1843 if ~eq(out(2).yunits, unit(yunits)), atest = false; end
1844 if ~eq(out(2).xunits, unit(xunits)), atest = false; end
1845 if ~strcmp(out(2).description, desc), atest = false; end
1846 % Check the re-built object
1847 if ~eq(mout, out, ple1), atest = false; end
1848 % </AlgoCode>
1849 % delete test file
1850 delete(filename);
1851 else
1852 atest = false;
1853 end
1854
1855 % Return a result structure
1856 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1857 end % END UTP_30
1858
1859
1860 %% UTP_31
1861
1862 % <TestDescription>
1863 %
1864 % Tests that the ao method properly applies history to the filename + plist constructor.
1865 %
1866 % </TestDescription>
1867 function result = utp_31
1868
1869 % <SyntaxDescription>
1870 %
1871 % Test that the output can be processed back to an m-file.
1872 %
1873 % </SyntaxDescription>
1874
1875 try
1876 % <SyntaxCode>
1877 fs = 10;
1878 Nsecs = 10;
1879 t0 = time('2008-02-15 14:00:00');
1880 col = [2 3];
1881 x1 = randn(1,Nsecs*fs);
1882 x2 = randn(1,Nsecs*fs);
1883 x3 = randn(1,Nsecs*fs);
1884
1885 %---- Save data as ascii file
1886 filename = 'data.txt';
1887 fd = fopen(filename, 'w+');
1888 % write header
1889 fprintf(fd, '%% A comment that should be read appropriately.\n');
1890 fprintf(fd, '%% \n');
1891 fprintf(fd, '%% M Hewitson\n');
1892 % write data
1893 for j=1:length(x1)
1894 fprintf(fd, '%.17g\t%.17g\t%.17g\n', x1(j), x2(j), x3(j));
1895 end
1896 % close file
1897 fclose(fd);
1898
1899 % Build plist
1900 desc = 'ao from filename';
1901 xunits = 's';
1902 yunits = {'V', 'V^2'};
1903
1904 pl = plist(...
1905 'description', desc,...
1906 'type', 'tsdata', ...
1907 'xunits', xunits, ...
1908 'yunits', yunits, ...
1909 'columns', col, ...
1910 'fs', fs, ...
1911 't0', {t0, t0+20}, ...
1912 'comment_char', '%');
1913
1914 out = ao(filename, pl);
1915 mout = rebuild(out);
1916 % </SyntaxCode>
1917 stest = true;
1918 catch err
1919 disp(err.message)
1920 stest = false;
1921 end
1922
1923 % <AlgoDescription>
1924 %
1925 % 1) Check that the last entry in the history of 'out' corresponds to
1926 % 'ao'.
1927 % 2) Check that the rebuilt object is the same as 'out'.
1928 %
1929 % </AlgoDescription>
1930
1931 atest = true;
1932 if stest
1933 % <AlgoCode>
1934 % Check the last step in the history of 'out'
1935 if ~strcmp(out(1).hist.methodInfo.mname, 'ao'), atest = false; end
1936 if ~strcmp(out(2).hist.methodInfo.mname, 'ao'), atest = false; end
1937 % Check data values
1938 if ~isa(out(1).data, 'tsdata'), atest = false; end
1939 if ~isa(out(2).data, 'tsdata'), atest = false; end
1940 if ~isequal(out(1).data.getY, x2.'), atest = false; end
1941 if ~isequal(out(2).data.getY, x3.'), atest = false; end
1942 if ~eq(unit(xunits), out(1).data.xunits), atest = false; end
1943 if ~eq(unit(yunits{1}), out(1).data.yunits), atest = false; end
1944 if ~eq(unit(xunits), out(2).data.xunits), atest = false; end
1945 if ~eq(unit(yunits{2}), out(2).data.yunits), atest = false; end
1946 if ~eq(out(1).data.t0, t0, ple1), atest = false; end
1947 if ~eq(out(2).data.t0, t0 + 20, ple1), atest = false; end
1948 if ~out(1).data.fs == fs, atest = false; end
1949 if ~out(2).data.fs == fs, atest = false; end
1950 % Check the rebuilt object
1951 if ~eq(mout, out, ple1), atest = false; end
1952 % </AlgoCode>
1953 % delete test file
1954 delete(filename)
1955 else
1956 atest = false;
1957 end
1958
1959 % Return a result structure
1960 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1961 end % END UTP_31
1962
1963
1964 end