% Test ao/pwelch functionality.
%
% M Hewitson 08-05-08
%
% $Id: test_ao_pwelch.m,v 1.7 2009/02/02 15:20:38 hewitson Exp $
%
function test_ao_pwelch()
  
  nsecs = 10;
  fs    = 1000;
  
  pl = plist(...
    'nsecs', nsecs, ...
    'fs', fs, 'tsfcn', ...
    '(t.^2 - (t.^3)/10) + sin(2*pi*7*t) + randn(size(t))');
  
  a1 = ao(pl);
  a2 = ao(pl);
  
  % Make PSDs
  Nfft = 2*fs;
  win = specwin('Hanning', Nfft);
  pl  = plist('Nfft', '2*fs', 'win', win, 'order', 2, 'Scale', 'ASD');
  a3 = psd(a1,pl);
  
  [pxx,f] = pwelch(a1.data.y, win.win, Nfft/2, Nfft, a1.data.fs);
  a4 = ao(fsdata(f.', pxx.'));
  
  % Plot
  iplot(a3, a4, plist('LineStyles', {'', '--'}))
  iplot(a3./a4)
  
end
% END