comparison testing/utp_1.1/utps/rational/utp_rational_resp.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents
children
comparison
equal deleted inserted replaced
43:bc767aaa99a8 44:409a22968d5e
1 % UTP_RATIONAL_RESP a set of UTPs for the rational/resp method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_rational_resp.m,v 1.7 2010/03/15 15:57:06 ingo Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The resp method of the rational class returns the complex response of a
11 % rational TF as an Analysis Object. For a command with no output variables
12 % plots the method the result into a diagram.
13 %
14 % </MethodDescription>
15
16 function results = utp_rational_resp(varargin)
17
18 % Check the inputs
19 if nargin == 0
20
21 % Some keywords
22 class = 'rational';
23 mthd = 'resp';
24
25 results = [];
26 disp('******************************************************');
27 disp(['**** Running UTPs for ' class '/' mthd]);
28 disp('******************************************************');
29
30 % Test RATIONAL objects
31 [ra1,ra2,ra3,rav,ram] = get_test_objects_rational;
32
33 % Exception list for the UTPs:
34 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
35
36 warning('This UTP needs a complete update');
37
38 % Run the tests
39 results = [results utp_01]; % getInfo call
40 results = [results utp_02]; % Vector input
41 results = [results utp_03]; % Matrix input
42 results = [results utp_04]; % List input
43 results = [results utp_05]; % Test with mixed input
44 results = [results utp_06]; % Test history is working
45 results = [results utp_07]; % Test the modify call works
46 results = [results utp_08]; % Test input data shape == output data shape
47 results = [results utp_09]; % Test output of the data
48 results = [results utp_10]; % Test with f = ao.y
49 results = [results utp_11]; % Test with f
50 results = [results utp_12]; % Test with f1, f2 and nf
51 results = [results utp_13]; % Test with f1, f2 and nf AND 'scale'
52
53 % Make surethat all figures are closed
54 close all;
55
56 disp('Done.');
57 disp('******************************************************');
58
59 elseif nargin == 1 % Check for UTP functions
60 if strcmp(varargin{1}, 'isutp')
61 results = 1;
62 else
63 results = 0;
64 end
65 else
66 error('### Incorrect inputs')
67 end
68
69 %% UTP_01
70
71 % <TestDescription>
72 %
73 % Tests that the getInfo call works for this method.
74 %
75 % </TestDescription>
76 function result = utp_01
77
78
79 % <SyntaxDescription>
80 %
81 % Test that the getInfo call works for no sets, all sets, and each set
82 % individually.
83 %
84 % </SyntaxDescription>
85
86 try
87 % <SyntaxCode>
88 % Call for no sets
89 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
90 % Call for all sets
91 io(2) = eval([class '.getInfo(''' mthd ''')']);
92 % Call for each set
93 for kk=1:numel(io(2).sets)
94 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
95 end
96 % </SyntaxCode>
97 stest = true;
98 catch err
99 disp(err.message)
100 stest = false;
101 end
102
103 % <AlgoDescription>
104 %
105 % 1) Check that getInfo call returned an minfo object in all cases.
106 % 2) Check that all plists have the correct parameters.
107 %
108 % </AlgoDescription>
109
110 atest = true;
111 if stest
112 % <AlgoCode>
113 % check we have minfo objects
114 if isa(io, 'minfo')
115 %%% SET 'None'
116 if ~isempty(io(1).sets), atest = false; end
117 if ~isempty(io(1).plists), atest = false; end
118 %%% Check all Sets
119 if ~any(strcmpi(io(2).sets, 'List')), atest = false; end
120 if ~any(strcmpi(io(2).sets, 'Range')), atest = false; end
121 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
122 %%%%%%%%%% SET 'List'
123 if io(3).plists.nparams ~= 2, atest = false; end
124 % Check key
125 if ~io(3).plists.isparam('f'), atest = false; end
126 if ~io(3).plists.isparam('bank'), atest = false; end
127 % Check default value
128 if ~isEmptyDouble(io(3).plists.find('f')), atest = false; end
129 if ~isequal(io(3).plists.find('bank'), 'none'), atest = false; end
130 % Check options
131 if ~isequal(io(3).plists.getOptionsForParam('f'), {[]}), atest = false; end
132 if ~isequal(io(3).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), atest = false; end
133 %%%%%%%%%% SET 'Range'
134 if io(4).plists.nparams ~= 5, atest = false; end
135 % Check key
136 if ~io(4).plists.isparam('f1'), atest = false; end
137 if ~io(4).plists.isparam('f2'), atest = false; end
138 if ~io(4).plists.isparam('nf'), atest = false; end
139 if ~io(4).plists.isparam('scale'), atest = false; end
140 if ~io(4).plists.isparam('bank'), atest = false; end
141 % Check default value
142 if ~isEmptyDouble(io(4).plists.find('f1')), atest = false; end
143 if ~isEmptyDouble(io(4).plists.find('f2')), atest = false; end
144 if ~isequal(io(4).plists.find('nf'), 1000), atest = false; end
145 if ~isequal(io(4).plists.find('scale'), 'log'), atest = false; end
146 if ~isequal(io(4).plists.find('bank'), 'none'), atest = false; end
147 % Check options
148 if ~isequal(io(4).plists.getOptionsForParam('f1'), {[]}), atest = false; end
149 if ~isequal(io(4).plists.getOptionsForParam('f2'), {[]}), atest = false; end
150 if ~isequal(io(4).plists.getOptionsForParam('nf'), {1000}), atest = false; end
151 if ~isequal(io(4).plists.getOptionsForParam('scale'), {'lin', 'log'}), atest = false; end
152 if ~isequal(io(4).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), atest = false; end
153 end
154 % </AlgoCode>
155 else
156 atest = false;
157 end
158
159 % Return a result structure
160 result = utp_prepare_result(atest, stest, dbstack, mfilename);
161 end % END UTP_01
162
163 %% UTP_02
164
165 % <TestDescription>
166 %
167 % Tests that the resp method works with a vector of RATIONAL objects as
168 % input.
169 %
170 % </TestDescription>
171 function result = utp_02
172
173 % <SyntaxDescription>
174 %
175 % Test that the resp method works for a vector of RATIONAL objects as
176 % input. Test the method with an output and with no output
177 % (a diagram must appear)
178 %
179 % </SyntaxDescription>
180
181 try
182 % <SyntaxCode>
183 % Make sure that all figures are closed.
184 close all;
185 resp(rav);
186 out = resp(rav);
187 % </SyntaxCode>
188 stest = true;
189 catch err
190 disp(err.message)
191 stest = false;
192 end
193
194 % <AlgoDescription>
195 %
196 % 1) Test the right number of lines in the diagram.
197 % 2) Check that the number of elements in 'out' is the same as in 'rav'
198 % 3) Check that each output RATIONAL contains the correct data.
199 %
200 % </AlgoDescription>
201
202 atest = true;
203 TOL = 1e-13;
204 if stest
205 % <AlgoCode>
206 % Get the current figure.
207 fi = gcf;
208 % Get ALL axes including the legends.
209 ax = get(fi, 'Children');
210 % Select only the 'axes' with the lines
211 ax = ax(ismember(get(ax(:), 'Tag'), ''));
212 % Get the lines of both axes
213 lines = get(ax(:), 'Children');
214 % Check that the diagram have the same number of lines as the output
215 % object
216 if max(cellfun('size', lines, 1)) ~= numel(rav), atest = false; end
217 % Check the number of output objects.
218 if ~isequal(size(out), size(rav)), atest = false; end
219 % Check each output against the default values for f1, f2 and nf
220 for ii = 1:numel(out)
221 f1 = getlowerFreq(rav(ii))/10;
222 f2 = getupperFreq(rav(ii))*10;
223 nf = 1000;
224 if ~isa(out(ii), 'ao'), atest = false; end
225 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
226 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
227 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
228 if numel(out(ii).x) ~= nf, atest = false; end
229 s = 2*pi*1i*out(ii).x;
230 numr = polyval(rav(ii).num, s);
231 denr = polyval(rav(ii).den, s);
232 rsp = numr./denr;
233 if ~isequal(out(ii).y, rsp), atest = false; end
234 end
235 % </AlgoCode>
236 else
237 atest = false;
238 end
239
240 % Return a result structure
241 result = utp_prepare_result(atest, stest, dbstack, mfilename);
242 end % END UTP_02
243
244 %% UTP_03
245
246 % <TestDescription>
247 %
248 % Tests that the resp method works with a matrix of RATIONAL objects as
249 % input.
250 %
251 % </TestDescription>
252 function result = utp_03
253
254 % <SyntaxDescription>
255 %
256 % Tests that the resp method works with a matrix of RATIONAL objects as
257 % input. Test the method with an output and with no output
258 % (a diagram must appear)
259 %
260 % </SyntaxDescription>
261
262 try
263 % <SyntaxCode>
264 % Make sure that all figures are closed.
265 close all;
266 resp(ram);
267 out = resp(ram);
268 % </SyntaxCode>
269 stest = true;
270 catch err
271 disp(err.message)
272 stest = false;
273 end
274
275 % <AlgoDescription>
276 %
277 % 1) Test the right number of lines in the diagram.
278 % 2) Check that the number of elements in 'out' is the same as in 'ram'
279 % 3) Check that each output RATIONAL contains the correct data.
280 %
281 % </AlgoDescription>
282
283 atest = true;
284 TOL = 1e-13;
285 if stest
286 % <AlgoCode>
287 % Get the current figure.
288 fi = gcf;
289 % Get ALL axes including the legends.
290 ax = get(fi, 'Children');
291 % Select only the 'axes' with the lines
292 ax = ax(ismember(get(ax(:), 'Tag'), ''));
293 % Get the lines of both axes
294 lines = get(ax(:), 'Children');
295 % Check that the diagram have the same number of lines as the output
296 % object
297 if max(cellfun('size', lines, 1)) ~= numel(ram), atest = false; end
298 % Check the number of output objects.
299 if ~isequal(size(out), size(ram)), atest = false; end
300 % Check each output against the default values for f1, f2 and nf
301 for ii = 1:numel(out)
302 f1 = getlowerFreq(ram(ii))/10;
303 f2 = getupperFreq(ram(ii))*10;
304 nf = 1000;
305 if ~isa(out(ii), 'ao'), atest = false; end
306 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
307 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
308 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
309 if numel(out(ii).x) ~= nf, atest = false; end
310 s = 2*pi*1i*out(ii).x;
311 numr = polyval(ram(ii).num, s);
312 denr = polyval(ram(ii).den, s);
313 rsp = numr./denr;
314 if ~isequal(out(ii).y, rsp), atest = false; end
315 end
316 % </AlgoCode>
317 else
318 atest = false;
319 end
320
321 % Return a result structure
322 result = utp_prepare_result(atest, stest, dbstack, mfilename);
323 end % END UTP_03
324
325 %% UTP_04
326
327 % <TestDescription>
328 %
329 % Tests that the resp method works with a list of RATIONAL objects as
330 % input.
331 %
332 % </TestDescription>
333 function result = utp_04
334
335 % <SyntaxDescription>
336 %
337 % Tests that the resp method works with a list of RATIONAL objects as
338 % input. Test the method with an output and with no output
339 % (a diagram must appear)
340 %
341 % </SyntaxDescription>
342
343 try
344 % <SyntaxCode>
345 % Make sure that all figures are closed.
346 close all;
347 resp(ra1, ra2, ra3);
348 out = resp(ra1, ra2, ra3);
349 % </SyntaxCode>
350 stest = true;
351 catch err
352 disp(err.message)
353 stest = false;
354 end
355
356 % <AlgoDescription>
357 %
358 % 1) Test the right number of lines in the diagram.
359 % 2) Check that the number of elements in 'out' is the same as in 'rain'
360 % 3) Check that each output RATIONAL contains the correct data.
361 %
362 % </AlgoDescription>
363
364 atest = true;
365 TOL = 1e-13;
366 rain = [ra1, ra2, ra3];
367 if stest
368 % <AlgoCode>
369 % Get the current figure.
370 fi = gcf;
371 % Get ALL axes including the legends.
372 ax = get(fi, 'Children');
373 % Select only the 'axes' with the lines
374 ax = ax(ismember(get(ax(:), 'Tag'), ''));
375 % Get the lines of both axes
376 lines = get(ax(:), 'Children');
377 % Check that the diagram have the same number of lines as the output
378 % object
379 if max(cellfun('size', lines, 1)) ~= numel(rain), atest = false; end
380 % Check the number of output objects.
381 if ~isequal(size(out), size(rain)), atest = false; end
382 % Check each output against the default values for f1, f2 and nf
383 for ii = 1:numel(out)
384 f1 = getlowerFreq(rain(ii))/10;
385 f2 = getupperFreq(rain(ii))*10;
386 nf = 1000;
387 if ~isa(out(ii), 'ao'), atest = false; end
388 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
389 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
390 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
391 if numel(out(ii).x) ~= nf, atest = false; end
392 s = 2*pi*1i*out(ii).x;
393 numr = polyval(rain(ii).num, s);
394 denr = polyval(rain(ii).den, s);
395 rsp = numr./denr;
396 if ~isequal(out(ii).y, rsp), atest = false; end
397 end
398 % </AlgoCode>
399 else
400 atest = false;
401 end
402
403 % Return a result structure
404 result = utp_prepare_result(atest, stest, dbstack, mfilename);
405 end % END UTP_04
406
407 %% UTP_05
408
409 % <TestDescription>
410 %
411 % Tests that the resp method works with a mix of different shaped
412 % RATIONAL objects as input.
413 %
414 % </TestDescription>
415 function result = utp_05
416
417 % <SyntaxDescription>
418 %
419 % Tests that the resp method works with a mix of different shaped
420 % RATIONAL objects as input. Test the method with an output and with no
421 % output (a diagram must appear)
422 %
423 % </SyntaxDescription>
424
425 try
426 % <SyntaxCode>
427 % Make sure that all figures are closed.
428 close all;
429 resp(ra1, ram, rav);
430 out = resp(ra1, ram, rav);
431 % </SyntaxCode>
432 stest = true;
433 catch err
434 disp(err.message)
435 stest = false;
436 end
437
438 % <AlgoDescription>
439 %
440 % 1) Test the right number of lines in the diagram.
441 % 2) Check that the number of elements in 'out' is the same as in 'rain'
442 % 3) Check that each output RATIONAL contains the correct data.
443 %
444 % </AlgoDescription>
445
446 atest = true;
447 TOL = 1e-13;
448 rain = [ra1, reshape(ram, 1, []), reshape(rav, 1, [])];
449 if stest
450 % <AlgoCode>
451 % Get the current figure.
452 fi = gcf;
453 % Get ALL axes including the legends.
454 ax = get(fi, 'Children');
455 % Select only the 'axes' with the lines
456 ax = ax(ismember(get(ax(:), 'Tag'), ''));
457 % Get the lines of both axes
458 lines = get(ax(:), 'Children');
459 % Check that the diagram have the same number of lines as the output
460 % object
461 if max(cellfun('size', lines, 1)) ~= numel(rain), atest = false; end
462 % Check the number of output objects.
463 if ~isequal(size(out), size(rain)), atest = false; end
464 % Check each output against the default values for f1, f2 and nf
465 for ii = 1:numel(out)
466 f1 = getlowerFreq(rain(ii))/10;
467 f2 = getupperFreq(rain(ii))*10;
468 nf = 1000;
469 if ~isa(out(ii), 'ao'), atest = false; end
470 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
471 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
472 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
473 if numel(out(ii).x) ~= nf, atest = false; end
474 s = 2*pi*1i*out(ii).x;
475 numr = polyval(rain(ii).num, s);
476 denr = polyval(rain(ii).den, s);
477 rsp = numr./denr;
478 if ~isequal(out(ii).y, rsp), atest = false; end
479 end
480 % </AlgoCode>
481 else
482 atest = false;
483 end
484
485 % Return a result structure
486 result = utp_prepare_result(atest, stest, dbstack, mfilename);
487 end % END UTP_05
488
489 %% UTP_06
490
491 % <TestDescription>
492 %
493 % Tests that the resp method properly applies history.
494 %
495 % </TestDescription>
496 function result = utp_06
497
498 % <SyntaxDescription>
499 %
500 % Test that the result of applying the resp method can be processed back.
501 %
502 % </SyntaxDescription>
503
504 try
505 % <SyntaxCode>
506 close all;
507 resp(ra1);
508 out = resp(ra1);
509 mout = rebuild(out);
510 % </SyntaxCode>
511 stest = true;
512 catch err
513 disp(err.message)
514 stest = false;
515 end
516
517 % <AlgoDescription>
518 %
519 % 1) Check that the last entry in the history of 'out' corresponds to
520 % 'resp'.
521 % 2) Check that re-built object is the same object as the input.
522 %
523 % </AlgoDescription>
524
525 atest = true;
526 if stest
527 % <AlgoCode>
528 % Get the current figure.
529 fi = gcf;
530 % Get ALL axes including the legends.
531 ax = get(fi, 'Children');
532 % Select only the 'axes' with the lines
533 ax = ax(ismember(get(ax(:), 'Tag'), ''));
534 % Get the lines of both axes
535 lines = get(ax(:), 'Children');
536 x = get(lines{1}, 'XData');
537 y1 = get(lines{1}, 'YData');
538 y2 = get(lines{2}, 'YData');
539 if ~isequal(x, out.x.'), atest = false; end
540 if ~isequal(y2, abs(out.y)'), atest = false; end
541 if ~isequal(y1, utils.math.phase(out.y)'), atest = false; end
542 % Check the last step in the history of 'out'
543 if ~strcmp(out.hist.methodInfo.mname, 'resp'), atest = false; end
544 % Run 'test.m' and check the result
545 if ~eq(mout, out, ple2), atest = false; end
546 % </AlgoCode>
547 else
548 atest = false;
549 end
550
551 % Return a result structure
552 result = utp_prepare_result(atest, stest, dbstack, mfilename);
553 end % END UTP_06
554
555 %% UTP_07
556
557 % <TestDescription>
558 %
559 % Tests that modify command plots the response into a diagram.
560 %
561 % </TestDescription>
562 function result = utp_07
563
564 % <SyntaxDescription>
565 %
566 % Tests that modify command plots the response into a diagram.
567 %
568 % </SyntaxDescription>
569
570 try
571 % <SyntaxCode>
572 close all;
573 ra1.resp();
574 % </SyntaxCode>
575 stest = true;
576 catch err
577 disp(err.message)
578 stest = false;
579 end
580
581 % <AlgoDescription>
582 %
583 % 1) Check the response diagram.
584 %
585 % </AlgoDescription>
586
587 atest = true;
588 TOL = 1e-13;
589 if stest
590 % <AlgoCode>
591 % Get the current figure.
592 fi = gcf;
593 % Get ALL axes including the legends.
594 ax = get(fi, 'Children');
595 % Select only the 'axes' with the lines
596 ax = ax(ismember(get(ax(:), 'Tag'), ''));
597 % Get the lines of both axes
598 lines = get(ax(:), 'Children');
599 x = get(lines{1}, 'XData');
600 f1 = getlowerFreq(ra1)/10;
601 f2 = getupperFreq(ra1)*10;
602 nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
603 if abs(x(1) - f1) > TOL, atest = false; end
604 if abs(x(end) - f2) > TOL, atest = false; end
605 if numel(x) ~= nf, atest = false; end
606 % </AlgoCode>
607 else
608 atest = false;
609 end
610
611 % Return a result structure
612 result = utp_prepare_result(atest, stest, dbstack, mfilename);
613 end % END UTP_07
614
615 %% UTP_08
616
617 % <TestDescription>
618 %
619 % Test the shape of the output.
620 %
621 % </TestDescription>
622 function result = utp_08
623
624 % <SyntaxDescription>
625 %
626 % Test that the output AO of the resp method keeps the shape of the used
627 % input f vector.
628 %
629 % </SyntaxDescription>
630
631 try
632 % <SyntaxCode>
633 arow = ao(1:123, linspace(.1, 5, 123));
634 acol = arow.';
635 f = linspace(.1, 5, 123);
636 out1 = resp(ra2, arow);
637 out2 = resp(ra2, acol);
638 out3 = resp(ra2, f);
639 % </SyntaxCode>
640 stest = true;
641 catch err
642 disp(err.message)
643 stest = false;
644 end
645
646 % <AlgoDescription>
647 %
648 % 1) Check that the shape of the data doesn't change.
649 %
650 % </AlgoDescription>
651
652 atest = true;
653 if stest
654 % <AlgoCode>
655 % Check the shape of the output data
656 if size(out1.data.y,1) ~= 1, atest = false; end
657 if size(out1.data.y,2) == 1, atest = false; end
658 if size(out2.data.y,1) == 1, atest = false; end
659 if size(out2.data.y,2) ~= 1, atest = false; end
660 if size(out3.data.y,1) ~= 1, atest = false; end
661 if size(out3.data.y,2) == 1, atest = false; end
662 % </AlgoCode>
663 else
664 atest = false;
665 end
666
667 % Return a result structure
668 result = utp_prepare_result(atest, stest, dbstack, mfilename);
669 end % END UTP_08
670
671 %% UTP_09
672
673 % <TestDescription>
674 %
675 % Check that the resp method pass back the output objects to a list of
676 % output variables or to a single variable.
677 %
678 % </TestDescription>
679 function result = utp_09
680
681 % <SyntaxDescription>
682 %
683 % Call the method with a list of output variables and with a single
684 % output variable. Additionaly check that the rebuild method works on
685 % the output.
686 %
687 % </SyntaxDescription>
688
689 try
690 % <SyntaxCode>
691 [o1, o2] = resp(ra1, ra1);
692 o3 = resp(ra1, ra1);
693 mout1 = rebuild(o1);
694 mout2 = rebuild(o2);
695 mout3 = rebuild(o3);
696 % </SyntaxCode>
697 stest = true;
698 catch err
699 disp(err.message)
700 stest = false;
701 end
702
703 % <AlgoDescription>
704 %
705 % 1) Check that the output contains the right number of objects
706 % 2) Check that the 'rebuild' method produces the same object as 'out'.
707 %
708 % </AlgoDescription>
709
710 atest = true;
711 if stest
712 % <AlgoCode>
713 % Check the number of outputs
714 if numel(o1) ~=1, atest = false; end
715 if numel(o2) ~=1, atest = false; end
716 if numel(o3) ~=2, atest = false; end
717 % Check the rebuilding of the object
718 if ~eq(o1, mout1, ple2), atest = false; end
719 if ~eq(o2, mout2, ple2), atest = false; end
720 if ~eq(o3, mout3, ple2), atest = false; end
721 % </AlgoCode>
722 else
723 atest = false;
724 end
725
726 % Return a result structure
727 result = utp_prepare_result(atest, stest, dbstack, mfilename);
728 end % END UTP_09
729
730 %% UTP_10
731
732 % <TestDescription>
733 %
734 % Check that the resp method uses the x-data of an input AO for f-vector.
735 %
736 % </TestDescription>
737 function result = utp_10
738
739 % <SyntaxDescription>
740 %
741 % Call the method with different method to pass an AO in.
742 %
743 % </SyntaxDescription>
744
745 try
746 % <SyntaxCode>
747 f1 = .1;
748 f2 = 5;
749 nf = 123;
750 axy = ao(linspace(f1, f2, nf), randn(nf,1));
751 afs = ao(linspace(f1, f2, nf), randn(nf,1), plist('type', 'fsdata'));
752 out1 = resp(ra3, axy);
753 out2 = resp(ra3, afs);
754 out3 = resp(ra3, plist('f', axy));
755 out4 = resp(ra3, plist('f', afs));
756
757 mout1 = rebuild(out1);
758 mout2 = rebuild(out2);
759 mout3 = rebuild(out3);
760 mout4 = rebuild(out4);
761 % </SyntaxCode>
762 stest = true;
763 catch err
764 disp(err.message)
765 stest = false;
766 end
767
768 % <AlgoDescription>
769 %
770 % 1) Check the output
771 % 2) Check that the 'rebuild' method produces the same object as 'out'.
772 %
773 % </AlgoDescription>
774
775 atest = true;
776 if stest
777 % <AlgoCode>
778 % Check the output
779 if ~isa(out1, 'ao'), atest = false; end
780 if ~isa(out2, 'ao'), atest = false; end
781 if ~isa(out3, 'ao'), atest = false; end
782 if ~isa(out4, 'ao'), atest = false; end
783 if out1.x(1) ~= f1, atest = false; end
784 if out1.x(end) ~= f2, atest = false; end
785 if numel(out1.x) ~= nf, atest = false; end
786 if out2.x(1) ~= f1, atest = false; end
787 if out2.x(end) ~= f2, atest = false; end
788 if numel(out2.x) ~= nf, atest = false; end
789 if out3.x(1) ~= f1, atest = false; end
790 if out3.x(end) ~= f2, atest = false; end
791 if numel(out3.x) ~= nf, atest = false; end
792 if out4.x(1) ~= f1, atest = false; end
793 if out4.x(end) ~= f2, atest = false; end
794 if numel(out4.x) ~= nf, atest = false; end
795 % Check the rebuilding of the object
796 if ~eq(out1, mout1, ple2), atest = false; end
797 if ~eq(out2, mout2, ple2), atest = false; end
798 if ~eq(out3, mout3, ple2), atest = false; end
799 if ~eq(out4, mout4, ple2), atest = false; end
800 % </AlgoCode>
801 else
802 atest = false;
803 end
804
805 % Return a result structure
806 result = utp_prepare_result(atest, stest, dbstack, mfilename);
807 end % END UTP_10
808
809 %% UTP_11
810
811 % <TestDescription>
812 %
813 % Check that the resp method uses the specified f-vector to compute the
814 % response.
815 %
816 % </TestDescription>
817 function result = utp_11
818
819 % <SyntaxDescription>
820 %
821 % Call the method with different method to pass an f-vector in.
822 %
823 % </SyntaxDescription>
824
825 try
826 % <SyntaxCode>
827 f1 = .1;
828 f2 = 5;
829 nf = 100;
830 f = linspace(f1, f2, nf);
831 out1 = resp(ra3, f);
832 out2 = resp(ra3, plist('f', f));
833
834 mout1 = rebuild(out1);
835 mout2 = rebuild(out2);
836 % </SyntaxCode>
837 stest = true;
838 catch err
839 disp(err.message)
840 stest = false;
841 end
842
843 % <AlgoDescription>
844 %
845 % 1) Check the output
846 % 2) Check that the 'rebuild' method produces the same object as 'out'.
847 %
848 % </AlgoDescription>
849
850 atest = true;
851 if stest
852 % <AlgoCode>
853 % Check the output
854 if ~isa(out1, 'ao'), atest = false; end
855 if ~isa(out2, 'ao'), atest = false; end
856 if out1.x(1) ~= f1, atest = false; end
857 if out1.x(end) ~= f2, atest = false; end
858 if numel(out1.x) ~= nf, atest = false; end
859 if out2.x(1) ~= f1, atest = false; end
860 if out2.x(end) ~= f2, atest = false; end
861 if numel(out2.x) ~= nf, atest = false; end
862 % Check the rebuilding of the object
863 if ~eq(out1, mout1, ple2), atest = false; end
864 if ~eq(out2, mout2, ple2), atest = false; end
865 % </AlgoCode>
866 else
867 atest = false;
868 end
869
870 % Return a result structure
871 result = utp_prepare_result(atest, stest, dbstack, mfilename);
872 end % END UTP_11
873
874 %% UTP_12
875
876 % <TestDescription>
877 %
878 % Check that the resp method uses the specified f1, f2, and nf to compute the response.
879 %
880 % </TestDescription>
881 function result = utp_12
882
883 % <SyntaxDescription>
884 %
885 % Call the method with different method to pass f1, f2, and nf in.
886 %
887 % </SyntaxDescription>
888
889 try
890 % <SyntaxCode>
891 f1 = .1;
892 f2 = 5;
893 nf = 100;
894 nf2 = 123;
895 out1 = resp(ra3, f1, f2);
896 out2 = resp(ra3, f1, f2, nf);
897 out3 = resp(ra3, plist('f1', f1, 'f2', f2, 'nf', nf));
898 out4 = resp(ra3, plist('f1', f1, 'nf', nf2));
899 out5 = resp(ra3, plist('f2', f2));
900
901 mout1 = rebuild(out1);
902 mout2 = rebuild(out2);
903 mout3 = rebuild(out3);
904 mout4 = rebuild(out4);
905 mout5 = rebuild(out5);
906 % </SyntaxCode>
907 stest = true;
908 catch err
909 disp(err.message)
910 stest = false;
911 end
912
913 % <AlgoDescription>
914 %
915 % 1) Check the output
916 % 2) Check that the 'rebuild' method produces the same object as 'out'.
917 %
918 % </AlgoDescription>
919
920 atest = true;
921 T = 10e-12;
922 if stest
923 % <AlgoCode>
924 % Check the output
925 f1d = getlowerFreq(ra3)/10;
926 f2d = getupperFreq(ra3)*10;
927 nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
928 if ~isa(out1, 'ao'), atest = false; end
929 if ~isa(out2, 'ao'), atest = false; end
930 if ~isa(out3, 'ao'), atest = false; end
931 if ~isa(out4, 'ao'), atest = false; end
932 if ~isa(out5, 'ao'), atest = false; end
933 if out1.x(1) ~= f1, atest = false; end
934 if abs(out1.x(end)-f2)>T, atest = false; end
935 if numel(out1.x) ~= nfd, atest = false; end % Default values
936 if out2.x(1) ~= f1, atest = false; end
937 if abs(out2.x(end)-f2)>T, atest = false; end
938 if numel(out2.x) ~= nf, atest = false; end
939 if out3.x(1) ~= f1, atest = false; end
940 if abs(out3.x(end)-f2)>T, atest = false; end
941 if numel(out3.x) ~= nf, atest = false; end
942 if out4.x(1) ~= f1, atest = false; end
943 if abs(out4.x(end) - f2d) > T, atest = false; end % Default values
944 if numel(out4.x) ~= nf2, atest = false; end
945 if out5.x(1) ~= f1d, atest = false; end % Default values
946 if abs(out5.x(end)-f2)>T, atest = false; end
947 if numel(out5.x) ~= nfd, atest = false; end % Default values
948 % Check the rebuilding of the object
949 if ~eq(out1, mout1, ple2), atest = false; end
950 if ~eq(out2, mout2, ple2), atest = false; end
951 if ~eq(out3, mout3, ple2), atest = false; end
952 if ~eq(out4, mout4, ple2), atest = false; end
953 if ~eq(out5, mout5, ple2), atest = false; end
954 % </AlgoCode>
955 else
956 atest = false;
957 end
958
959 % Return a result structure
960 result = utp_prepare_result(atest, stest, dbstack, mfilename);
961 end % END UTP_12
962
963 %% UTP_13
964
965 % <TestDescription>
966 %
967 % Check that the resp method uses the specified f1, f2, and nf to compute
968 % the response.
969 %
970 % </TestDescription>
971 function result = utp_13
972
973 % <SyntaxDescription>
974 %
975 % Call the method with different method to pass f1, f2, and nf in.
976 %
977 % </SyntaxDescription>
978
979 try
980 % <SyntaxCode>
981 f1 = .1;
982 f2 = 5;
983 nf = 123;
984 out1 = resp(ra3, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'lin'));
985 out2 = resp(ra3, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'log'));
986 out3 = resp(ra3, plist('scale', 'lin'));
987 out4 = resp(ra3, plist('scale', 'log'));
988
989 mout1 = rebuild(out1);
990 mout2 = rebuild(out2);
991 mout3 = rebuild(out3);
992 mout4 = rebuild(out4);
993 % </SyntaxCode>
994 stest = true;
995 catch err
996 disp(err.message)
997 stest = false;
998 end
999
1000 % <AlgoDescription>
1001 %
1002 % 1) Check the output
1003 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1004 %
1005 % </AlgoDescription>
1006
1007 atest = true;
1008 T = 10e-12;
1009 if stest
1010 % <AlgoCode>
1011 % Check the output
1012 f1d = getlowerFreq(ra3)/10;
1013 f2d = getupperFreq(ra3)*10;
1014 nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
1015 if ~isa(out1, 'ao'), atest = false; end
1016 if ~isa(out2, 'ao'), atest = false; end
1017 if ~isa(out3, 'ao'), atest = false; end
1018 if ~isa(out4, 'ao'), atest = false; end
1019 xlin1 = linspace(f1, f2, nf);
1020 xlin2 = linspace(f1d, f2d, nfd);
1021 xlog1 = logspace(log10(f1), log10(f2), nf);
1022 xlog2 = logspace(log10(f1d), log10(f2d), nfd);
1023 if ~isequal(xlin1, out1.x'), atest = false; end
1024 if ~isequal(xlin2, out3.x'), atest = false; end
1025 if ~isequal(xlog1, out2.x'), atest = false; end
1026 if ~isequal(xlog2, out4.x'), atest = false; end
1027
1028 % Check the rebuilding of the object
1029 if ~eq(out1, mout1, ple2), atest = false; end
1030 if ~eq(out2, mout2, ple2), atest = false; end
1031 if ~eq(out3, mout3, ple2), atest = false; end
1032 if ~eq(out4, mout4, ple2), atest = false; end
1033 % </AlgoCode>
1034 else
1035 atest = false;
1036 end
1037
1038 % Return a result structure
1039 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1040 end % END UTP_13
1041
1042 end