comparison testing/utp_1.1/utps/ao/utp_ao_lcpsd.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_AO_LCPSD a set of UTPs for the ao/lcpsd method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_ao_lcpsd.m,v 1.29 2011/07/22 11:51:46 mauro Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The lcpsd method of the ao class computes the cross-spectral density between two
11 % time-series AOs on a log-frequency axis.
12 %
13 % </MethodDescription>
14
15 function results = utp_ao_lcpsd(varargin)
16
17 % Check the inputs
18 if nargin == 0
19
20 % Some keywords
21 class = 'ao';
22 mthd = 'lcpsd';
23
24 results = [];
25 disp('******************************************************');
26 disp(['**** Running UTPs for ' class '/' mthd]);
27 disp('******************************************************');
28
29 % Test AOs
30 [at1,at2,at3,at4,at5,at6] = eval(['get_test_objects_' class]);
31
32 % Exception list for the UTPs:
33 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
34
35 % Get default window from the preferences
36 prefs = getappdata(0, 'LTPDApreferences');
37 defaultWinType = char(prefs.getMiscPrefs.getDefaultWindow);
38
39 % Run the tests
40 results = [results utp_01]; % getInfo call
41 results = [results utp_02]; % Vector input (only with two objects)
42 results = [results utp_03]; % Matrix input (not possible)
43 results = [results utp_04]; % List input (only with two objects)
44 results = [results utp_05]; % Test with mixed input (not possible)
45 results = [results utp_06]; % Test history is working
46 results = [results utp_07]; % Test the modify call works
47 results = [results utp_08]; % Test input data shape == output data shape
48 results = [results utp_09]; % Test output of the data
49 results = [results utp_11(mthd, [at1 at1], ple1)]; % Test plotinfo doesn't disappear
50 results = [results utp_12]; % Test data lengths
51 results = [results utp_17]; % Test units handling: LCPSD
52 results = [results utp_18]; % Comparison with PSD
53
54 disp('Done.');
55 disp('******************************************************');
56
57 elseif nargin == 1 % Check for UTP functions
58 if strcmp(varargin{1}, 'isutp')
59 results = 1;
60 else
61 results = 0;
62 end
63 else
64 error('### Incorrect inputs')
65 end
66
67 %% UTP_01
68
69 % <TestDescription>
70 %
71 % Tests that the getInfo call works for this method.
72 %
73 % </TestDescription>
74 function result = utp_01
75
76
77 % <SyntaxDescription>
78 %
79 % Test that the getInfo call works for no sets, all sets, and each set
80 % individually.
81 %
82 % </SyntaxDescription>
83
84 try
85 % <SyntaxCode>
86 % Call for no sets
87 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
88 % Call for all sets
89 io(2) = eval([class '.getInfo(''' mthd ''')']);
90 % Call for each set
91 for kk=1:numel(io(2).sets)
92 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
93 end
94 % </SyntaxCode>
95 stest = true;
96 catch err
97 disp(err.message)
98 stest = false;
99 end
100
101 % <AlgoDescription>
102 %
103 % 1) Check that getInfo call returned an minfo object in all cases.
104 % 2) Check that all plists have the correct parameters.
105 %
106 % </AlgoDescription>
107
108 atest = true;
109 if stest
110 % <AlgoCode>
111 % check we have minfo objects
112 if isa(io, 'minfo')
113
114 % SET 'None'
115 if ~isempty(io(1).sets), atest = false; end
116 if ~isempty(io(1).plists), atest = false; end
117 % Check all Sets
118 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
119 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
120 % SET 'Default'
121 if io(3).plists.nparams ~= 9, atest = false; end
122 % Check key
123 if ~io(3).plists.isparam('kdes'), atest = false; end
124 if ~io(3).plists.isparam('jdes'), atest = false; end
125 if ~io(3).plists.isparam('lmin'), atest = false; end
126 if ~io(3).plists.isparam('win'), atest = false; end
127 if ~io(3).plists.isparam('olap'), atest = false; end
128 if ~io(3).plists.isparam('order'), atest = false; end
129 if ~io(3).plists.isparam('psll'), atest = false; end
130 if ~io(3).plists.isparam('times'), atest = false; end
131 if ~io(3).plists.isparam('split'), atest = false; end
132 % Check default value
133 if ~isequal(io(3).plists.find('kdes'), 100), atest = false; end
134 if ~isequal(io(3).plists.find('jdes'), 1000), atest = false; end
135 if ~isequal(io(3).plists.find('lmin'), 0), atest = false; end
136 if ~strcmpi(io(3).plists.find('win'), defaultWinType), atest = false; end
137 if ~isequal(io(3).plists.find('olap'), -1), atest = false; end
138 if ~isequal(io(3).plists.find('order'), 0), atest = false; end
139 if ~isequal(io(3).plists.find('psll'), 200), atest = false; end
140 if ~isEmptyDouble(io(3).plists.find('times')), atest = false; end
141 if ~isEmptyDouble(io(3).plists.find('split')), atest = false; end
142 % Check options
143 if ~isequal(io(3).plists.getOptionsForParam('kdes'), {100}), atest = false; end
144 if ~isequal(io(3).plists.getOptionsForParam('jdes'), {1000}), atest = false; end
145 if ~isequal(io(3).plists.getOptionsForParam('lmin'), {0}), atest = false; end
146 if ~isequal(io(3).plists.getOptionsForParam('win'), specwin.getTypes), atest = false; end
147 if ~isequal(io(3).plists.getOptionsForParam('olap'), {-1}), atest = false; end
148 if ~isequal(io(3).plists.getOptionsForParam('order'), {-1 0 1 2 3 4 5 6 7 8 9}), atest = false; end
149 if ~isequal(io(3).plists.getOptionsForParam('psll'), {200}), atest = false; end
150 if ~isequal(io(3).plists.getOptionsForParam('times'), {[]}), atest = false; end
151 if ~isequal(io(3).plists.getOptionsForParam('split'), {[]}), atest = false; end
152 end
153 % </AlgoCode>
154 else
155 atest = false;
156 end
157
158 % Return a result structure
159 result = utp_prepare_result(atest, stest, dbstack, mfilename);
160 end % END UTP_01
161
162 %% UTP_02
163
164 % <TestDescription>
165 %
166 % Tests that the lcpsd method works with a vector of AOs as input. (only
167 % with two objects in the vector)
168 %
169 % </TestDescription>
170 function result = utp_02
171
172 % <SyntaxDescription>
173 %
174 % Test that the lcpsd method works for a vector of AOs as input.
175 %
176 % </SyntaxDescription>
177
178 try
179 % <SyntaxCode>
180 avec = [at1 at5];
181 out = lcpsd(avec);
182 % </SyntaxCode>
183 stest = true;
184 catch err
185 disp(err.message)
186 stest = false;
187 end
188
189 % <AlgoDescription>
190 %
191 % 1) Check that the number of elements in 'out' is equal to 1
192 %
193 % </AlgoDescription>
194
195 atest = true;
196 if stest
197 % <AlgoCode>
198 % Check we have the correct number of outputs
199 if numel(out) ~= 1, atest = false; end
200 % </AlgoCode>
201 else
202 atest = false;
203 end
204
205 % Return a result structure
206 result = utp_prepare_result(atest, stest, dbstack, mfilename);
207 end % END UTP_02
208
209 %% UTP_03
210
211 % <TestDescription>
212 %
213 % Tests that the lcpsd method doesn't work with a matrix of AOs as input.
214 %
215 % </TestDescription>
216 function result = utp_03
217
218 % <SyntaxDescription>
219 %
220 % Test that the lcpsd method doesn't work for a matrix of AOs as input.
221 %
222 % </SyntaxDescription>
223
224 try
225 % <SyntaxCode>
226 amat = [at1 at5; at5 at6];
227 out = lcpsd(amat);
228 % </SyntaxCode>
229 stest = false;
230 catch err
231 stest = true;
232 end
233
234 % <AlgoDescription>
235 %
236 % 1) Nothing to check.
237 %
238 % </AlgoDescription>
239
240 atest = true;
241 if stest
242 % <AlgoCode>
243 % </AlgoCode>
244 else
245 atest = false;
246 end
247
248 % Return a result structure
249 result = utp_prepare_result(atest, stest, dbstack, mfilename);
250 end % END UTP_03
251
252 %% UTP_04
253
254 % <TestDescription>
255 %
256 % Tests that the lcpsd method works with a list of AOs as input.
257 %
258 % </TestDescription>
259 function result = utp_04
260
261 % <SyntaxDescription>
262 %
263 % Test that the lcpsd method works for a list of AOs as input.
264 %
265 % </SyntaxDescription>
266
267 try
268 % <SyntaxCode>
269 out = lcpsd(at1,at5);
270 % </SyntaxCode>
271 stest = true;
272 catch err
273 disp(err.message)
274 stest = false;
275 end
276
277 % <AlgoDescription>
278 %
279 % 1) Check that the number of elements in 'out' is equal to 1
280 %
281 % </AlgoDescription>
282
283 atest = true;
284 if stest
285 % <AlgoCode>
286 % Check we have the correct number of outputs
287 if numel(out) ~= 1, atest = false; end
288 % </AlgoCode>
289 else
290 atest = false;
291 end
292
293 % Return a result structure
294 result = utp_prepare_result(atest, stest, dbstack, mfilename);
295 end % END UTP_04
296
297 %% UTP_05
298
299 % <TestDescription>
300 %
301 % Tests that the lcpsd method doesn't work with a mix of different shaped
302 % AOs as input.
303 %
304 % </TestDescription>
305 function result = utp_05
306
307 % <SyntaxDescription>
308 %
309 % Test that the lcpsd method doesn't work with an input of matrices and
310 % vectors and single AOs.
311 %
312 % </SyntaxDescription>
313
314 try
315 % <SyntaxCode>
316 out = lcpsd(at1,[at5 at6],at5,[at5 at1; at6 at1],at6);
317 stest = false;
318 % </SyntaxCode>
319 catch err
320 stest = true;
321 end
322
323 % <AlgoDescription>
324 %
325 % 1) Nothing to check
326 %
327 % </AlgoDescription>
328
329 atest = true;
330 if stest
331 % <AlgoCode>
332 % </AlgoCode>
333 else
334 atest = false;
335 end
336
337 % Return a result structure
338 result = utp_prepare_result(atest, stest, dbstack, mfilename);
339 end % END UTP_05
340
341 %% UTP_06
342
343 % <TestDescription>
344 %
345 % Tests that the lcpsd method properly applies history.
346 %
347 % </TestDescription>
348 function result = utp_06
349
350 % <SyntaxDescription>
351 %
352 % Test that the result of applying the lcpsd method can be processed back
353 % to an m-file.
354 %
355 % </SyntaxDescription>
356
357 try
358 % <SyntaxCode>
359 out = lcpsd(at5,at6);
360 mout = rebuild(out);
361 % </SyntaxCode>
362 stest = true;
363 catch err
364 disp(err.message)
365 stest = false;
366 end
367
368 % <AlgoDescription>
369 %
370 % 1) Check that the last entry in the history of 'out' corresponds to
371 % 'cpsd'.
372 % 2) Check that the re-built object is the same as 'out'.
373 %
374 % </AlgoDescription>
375
376 atest = true;
377 if stest
378 % <AlgoCode>
379 % Check the last step in the history of 'out'
380 if ~strcmp(out.hist.methodInfo.mname, 'lcpsd'), atest = false; end
381 % Check the re-built object
382 if ~eq(mout, out, ple2), atest = false; end
383 % </AlgoCode>
384 else
385 atest = false;
386 end
387
388 % Return a result structure
389 result = utp_prepare_result(atest, stest, dbstack, mfilename);
390 end % END UTP_06
391
392 %% UTP_07
393
394 % <TestDescription>
395 %
396 % Tests that the lcpsd method can not modify the input AO.
397 %
398 % </TestDescription>
399 function result = utp_07
400
401 % <SyntaxDescription>
402 %
403 % Test that the lcpsd method can not modify the input AO.
404 % The method must throw an error for the modifier call.
405 %
406 % </SyntaxDescription>
407
408 try
409 % <SyntaxCode>
410 % copy at1 to work with
411 ain = ao(at1);
412 % modify ain
413 ain.lcpsd(at5);
414 % </SyntaxCode>
415 stest = false;
416 catch err
417 stest = true;
418 end
419
420 % <AlgoDescription>
421 %
422 % 1) Nothing to check.
423 %
424 % </AlgoDescription>
425
426 atest = true;
427 if stest
428 % <AlgoCode>
429 % </AlgoCode>
430 else
431 atest = false;
432 end
433
434 % Return a result structure
435 result = utp_prepare_result(atest, stest, dbstack, mfilename);
436 end % END UTP_07
437
438 %% UTP_08
439
440 % <TestDescription>
441 %
442 % Test the shape of the output.
443 %
444 % </TestDescription>
445 function result = utp_08
446
447 % <SyntaxDescription>
448 %
449 % Test that the lcpsd method keeps the data shape of the input object. The
450 % input AO must be an AO with row data and an AO with column data.
451 %
452 % </SyntaxDescription>
453
454 try
455 % <SyntaxCode>
456 out1 = lcpsd(at5, at6);
457 out2 = lcpsd(at6, at5);
458 % </SyntaxCode>
459 stest = true;
460 catch err
461 disp(err.message)
462 stest = false;
463 end
464
465 % <AlgoDescription>
466 %
467 % 1) Check that the shape of the output data doesn't change.
468 %
469 % </AlgoDescription>
470
471 atest = true;
472 if stest
473 % <AlgoCode>
474 % Check the shape of the output data
475 if size(out1.data.y, 2) ~= 1, atest = false; end
476 if size(out2.data.y, 1) ~= 1, atest = false; end
477 % </AlgoCode>
478 else
479 atest = false;
480 end
481
482 % Return a result structure
483 result = utp_prepare_result(atest, stest, dbstack, mfilename);
484 end % END UTP_08
485
486 %% UTP_09
487
488 % <TestDescription>
489 %
490 % Check that the lcpsd method pass back the output objects to a list of
491 % output variables or to a single variable.
492 %
493 % </TestDescription>
494 function result = utp_09
495
496 % <SyntaxDescription>
497 %
498 % This test is not longer necessary because the lcpsd method pass back
499 % always only one object.
500 %
501 % </SyntaxDescription>
502
503 try
504 % <SyntaxCode>
505 % </SyntaxCode>
506 stest = true;
507 catch err
508 disp(err.message)
509 stest = false;
510 end
511
512 % <AlgoDescription>
513 %
514 % 1) Nothing to check.
515 %
516 % </AlgoDescription>
517
518 atest = true;
519 if stest
520 % <AlgoCode>
521 % </AlgoCode>
522 else
523 atest = false;
524 end
525
526 % Return a result structure
527 result = utp_prepare_result(atest, stest, dbstack, mfilename);
528 end % END UTP_09
529
530 %% UTP_12
531
532 % <TestDescription>
533 %
534 % Tests that differently sized data sets are treated properly
535 %
536 % </TestDescription>
537 function result = utp_12
538
539 % <SyntaxDescription>
540 %
541 % Test that applying lcpsd works on two AOs.
542 %
543 % </SyntaxDescription>
544
545 try
546 % <SyntaxCode>
547 % Construct two test AOs
548 nsecs = [10000:1:20000];
549 fs = 1;
550 pl = plist('fs', fs, 'tsfcn', 'randn(size(t))');
551 a1 = ao(pl.pset('nsecs', utils.math.randelement(nsecs, 1)));
552 a2 = ao(pl.pset('nsecs', utils.math.randelement(nsecs, 1)));
553 len_1 = a1.len;
554 len_2 = a2.len;
555 % Filter one time-series
556 f2 = miir(plist('type', 'bandpass', 'fs', fs, 'order', 3, 'fc', [.050 .25]));
557 a1f = filter(a1, plist('filter', f2));
558 % Compute lcpsd
559 win = 'Hanning';
560 pl = plist('Win', win, 'order', -1);
561 out = lcpsd(a2,a1f,pl);
562
563 stest = true;
564 % </SyntaxCode>
565 catch err
566 disp(err.message)
567 stest = false;
568 end
569
570 % <AlgoDescription>
571 %
572 % 1) Check that lcpsd used the length of the shortest ao.
573 %
574 % </AlgoDescription>
575
576 atest = true;
577 if stest
578 % <AlgoCode>
579 % Compare the nfft with the length of the input data
580
581 if out.x(1) ~= 1/min(len_1,len_2)
582 atest = false;
583 end
584 % </AlgoCode>
585 else
586 atest = false;
587 end
588
589 % Return a result structure
590 result = utp_prepare_result(atest, stest, dbstack, mfilename);
591 end % END UTP_12
592
593 %% UTP_17
594
595 % <TestDescription>
596 %
597 % Tests handling of units:
598 % 1) white noise produced from normal pdf, with a given mean value and
599 % sigma (distribution's 1st and 2nd orders)
600 % 2) white noise produced from normal pdf, with a given mean value and
601 % sigma (distribution's 1st and 2nd orders)
602 % 3) LCPSD of the white noise series
603 % 4) compares the units of the input and output
604 %
605
606 % </TestDescription>
607 function result = utp_17
608
609 % <SyntaxDescription>
610 %
611 % 1) Prepare the test tsdata:
612 % white noise from normal distribution + offset
613 % 2) Assign a random unit
614 % 3) Prepare the test tsdata:
615 % white noise from normal distribution + offset
616 % 4) Assign a random unit
617 % 5) LCPSD of the white noise
618 %
619 % </SyntaxDescription>
620
621 % <SyntaxCode>
622 try
623
624 noise_type = 'Normal';
625 win_type = 'BH92';
626
627 [a_1, a_2, spec, spec1] = prepare_analyze_noise(win_type, noise_type, plist);
628
629 stest = true;
630
631 catch err
632 disp(err.message)
633 stest = false;
634 end
635 % </SyntaxCode>
636
637 % <AlgoDescription>
638 %
639 % 1) Check that (calculated LCPSD yunits) equals
640 % input_1 units*input_2 units/Hz
641 %
642 % </AlgoDescription>
643
644 % <AlgoCode>
645 atest = true;
646 u = simplifyYunits(a_1.* a_2, plist('prefixes', false, 'exceptions', 'Hz'));
647 if stest
648 if ne(spec.Cxy.yunits, u.yunits * unit('Hz^-1')) || ne(spec.Cxy.xunits, unit('Hz'))
649 atest = false;
650 end
651 if ne(spec.Cyx.yunits, u.yunits * unit('Hz^-1')) || ne(spec.Cyx.xunits, unit('Hz'))
652 atest = false;
653 end
654 else
655 atest = false;
656 end
657 % </AlgoCode>
658
659 % Return a result structure
660 result = utp_prepare_result(atest, stest, dbstack, mfilename);
661 end % END UTP_17
662
663 %% UTP_18
664
665 % <TestDescription>
666 %
667 % Tests handling of units:
668 % 1) white noise produced from normal pdf, with a given mean value and
669 % sigma (distribution's 1st and 2nd orders)
670 % 2) white noise produced from normal pdf, with a given mean value and
671 % sigma (distribution's 1st and 2nd orders)
672 % 3) LCPSD of the white noise series
673 %
674 % Comparison with LPSD:
675 % 4) compares the off-diagonal terms to check they are complex-conjugated
676 % 5) compares the diagonal terms with PSD of the individual noise
677 %
678
679 % </TestDescription>
680 function result = utp_18
681
682 % <SyntaxDescription>
683 %
684 % 1) Prepare the test tsdata:
685 % white noise from normal distribution + offset
686 % 2) Assign a random unit
687 % 3) Prepare the test tsdata:
688 % white noise from normal distribution + offset
689 % 4) Assign a random unit
690 % 5) LCPSD of the white noise
691 % 6) LPSD of the white noise
692 %
693 % </SyntaxDescription>
694
695 % <SyntaxCode>
696 try
697
698 noise_type = 'Uniform';
699 win_type = 'BH92';
700
701 [a_1, a_2, spec, spec2] = prepare_analyze_noise(win_type, noise_type, plist);
702
703 stest = true;
704
705 catch err
706 disp(err.message)
707 stest = false;
708 end
709 % </SyntaxCode>
710
711 % <AlgoDescription>
712 %
713 % 1) Check that LCPSD(x,y) equals conj(LCPSD(y,x))
714 % 2) Check that LCPSD(y,y) equals LPSD(y)
715 % 3) Check that LCPSD(x,x) equals LPSD(x)
716
717 %
718 % </AlgoDescription>
719
720 % <AlgoCode>
721 atest = true;
722 TOL = 1e-12;
723
724 if stest
725 if ne(spec.Cxy.y, conj(spec.Cyx.y)), atest = false; end
726 if ne(spec.Cxy.x, spec.Cyx.x), atest = false; end
727 if ne(spec.Cxx.data, spec.S_1.data)
728 if any(abs(spec.Cxx.y - spec.S_1.y)./abs(spec.Cxx.y) > TOL)
729 atest = false;
730 end
731 end
732 if ne(spec.Cyy.data, spec.S_2.data)
733 if any(abs(spec.Cyy.y - spec.S_2.y)./abs(spec.Cyy.y) > TOL)
734 atest = false;
735 end
736 end
737 else
738 atest = false;
739 end
740 % </AlgoCode>
741
742 % Return a result structure
743 result = utp_prepare_result(atest, stest, dbstack, mfilename);
744 end % END UTP_18
745
746 %% Helper function for window call construction
747
748 function [a_1, a_2, spec1, spec2] = prepare_analyze_noise(win_type, noise_type, pli)
749 % Array of parameters to pick from
750 fs_list = [0.1;1;2;5;10];
751 nsecs_list = [20 100 1000:1000:10000]';
752 sigma_distr_list = [1e-6 2e-3 0.25 1:0.1:10]';
753 trend_0_list = [1e-6 2e-3 0.25 1:0.1:10]';
754
755
756 % Build time-series test data
757
758 % Picks the values at random from the list
759 fs = utils.math.randelement(fs_list, 1);
760 nsecs = utils.math.randelement(nsecs_list, 1);
761 sigma_distr_1 = utils.math.randelement(sigma_distr_list, 1);
762 sigma_distr_2 = utils.math.randelement(sigma_distr_list, 1);
763 trend_0_1 = utils.math.randelement(trend_0_list, 1);
764 trend_0_2 = utils.math.randelement(trend_0_list, 1);
765
766 % Pick units and prefix from those supported
767 unit_list = unit.supportedUnits;
768 % remove the first empty unit '' from the list, because then is it
769 % possible that we add a prefix to an empty unit
770 unit_list = unit_list(2:end);
771 prefix_list = unit.supportedPrefixes;
772
773 % White noise
774 a_n = ao(plist('waveform', 'noise', ...
775 'type', noise_type, 'fs', fs, 'nsecs', nsecs, 'sigma', sigma_distr_1));
776
777 % Constant signal
778 a_c = ao(trend_0_1);
779
780 % Total signal
781 a_1 = a_n + a_c;
782
783 % White noise
784 a_n = ao(plist('waveform', 'noise', ...
785 'type', noise_type, 'fs', fs, 'nsecs', nsecs, 'sigma', sigma_distr_2));
786 % Constant signal
787 a_c = ao(trend_0_2);
788
789 % Total signal
790 a_2 = a_n + a_c;
791
792 % Set units
793 a_1.setYunits(unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))]));
794 a_2.setYunits(unit([cell2mat(utils.math.randelement(prefix_list,1)) cell2mat(utils.math.randelement(unit_list,1))]));
795
796 % Evaluate the lcpsd of the white noise time-series data
797 olap = 0;
798 detrend_order = 0;
799
800 switch lower(win_type)
801 case 'kaiser'
802 psll = find(pli, 'psll');
803 if isempty(psll)
804 psll = find(ao.getInfo('psd').plists, 'psll');
805 end
806 pl_spec = plist('Win', win_type, 'psll', psll, 'olap', olap, 'order', detrend_order);
807
808 otherwise
809 pl_spec = plist('Win', win_type, 'olap', olap, 'order', detrend_order);
810
811 end
812
813 if find(pli, 'win_obj')
814 % Calls the lcpsd applying the detrend and window internally
815 % (passig window object)
816 spec2.pl = pl_spec;
817 spec2.Cxy = lcpsd(a_1, a_2, spec2.pl);
818 spec2.Cyx = lcpsd(a_2, a_1, spec2.pl);
819 spec2.Cxx = lcpsd(a_1, a_1, spec2.pl);
820 spec2.Cyy = lcpsd(a_2, a_2, spec2.pl);
821 spec2.S_1 = simplifyYunits(lpsd(a_1, spec2.pl), ...
822 plist('prefixes', false, 'exceptions','Hz'));
823 spec2.S_2 = simplifyYunits(lpsd(a_2, spec2.pl), ...
824 plist('prefixes', false, 'exceptions','Hz'));
825 else
826 spec2 = struct;
827 end
828 % Calls the lcpsd applying the detrend and window internally
829 % (passig window name)
830 spec1.pl = pl_spec.pset('Win', win_type);
831 spec1.Cxy = lcpsd(a_1, a_2, spec1.pl);
832 spec1.Cyx = lcpsd(a_2, a_1, spec1.pl);
833 spec1.Cxx = lcpsd(a_1, a_1, spec1.pl);
834 spec1.Cyy = lcpsd(a_2, a_2, spec1.pl);
835 spec1.S_1 = simplifyYunits(lpsd(a_1, spec1.pl), ...
836 plist('prefixes', false, 'exceptions','Hz'));
837 spec1.S_2 = simplifyYunits(lpsd(a_2, spec1.pl), ...
838 plist('prefixes', false, 'exceptions','Hz'));
839
840 end
841
842 end