view m-toolbox/test/test_ao_lcpsd.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

% Test ao/cpsd functionality.
%
% M Hewitson 08-05-08
%
% $Id: test_ao_lcpsd.m,v 1.1 2009/03/26 09:04:05 miquel Exp $
%
 function test_ao_lcpsd()
  
%   Make test AOs
  
  nsecs = 10;
  fs    = 1000;
  
  pl = plist();
  pl.append('nsecs', nsecs);
  pl.append('fs', fs);
  pl.append('tsfcn', 'sin(2*pi*7.433*t) + randn(size(t))');
  
  a1 = ao(pl);
  a2 = ao(pl);
  
  % Filter one time-series
  
  % Make a filter
  pl = plist('type', 'bandpass', 'fs', 1000, 'order', 3, 'fc', [50 250]);
  f2 = miir(pl);
  
  % filter the input data
  [a3, f2] = filter(a1,plist('filter', f2));
  
  % make some cross-power
  a4 = 10.*a3+a2;
  
  % Make CPSD from a6 to a7
  Nfft = 1000;
  win = specwin('Hanning',Nfft)
  pl = plist('Win', 'Hanning', 'order', 2);
  a8 = cpsd(a1, a4, pl);
  
  % Use matlab
  [pxy, f] = cpsd(a1.data.y, a4.data.y, win.win, Nfft/2, Nfft, a1.data.fs);
  a9 = ao(fsdata(f.', pxy.'));
  
  % Plot
  iplot(a8, a9, plist('LineStyles', {'', '--'}))
 
  
  % Test cpsd(a1,a1) = psd(a1)
  a10 = lcpsd(a1, a1, pl);
  a11 = lpsd(a1, pl);
  
  iplot(a10,a11)
  
 end