view m-toolbox/test/test_ao_cohere.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line source

% Test ao/cohere functionality.
%
% M Hewitson 08-05-08
%
% $Id: test_ao_cohere.m,v 1.6 2009/04/07 17:45:22 ingo Exp $
%
function test_ao_cohere()
  
  % Make test AOs
  
  nsecs = 10;
  fs    = 1000;
  
  pl = plist('nsecs', nsecs, 'fs', fs, '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 = a3+a2;
  a4.setName;
  
  % Make cohere from a6 to a7
  Nfft = 1000*2;
  win  = specwin('Hanning', Nfft);
  pl = plist('Nfft', Nfft, 'Win', win, 'order', 2);
  a8 = cohere(a4, a1, pl);
  
  
  % Do with MATLAB
  [cxy, f] = mscohere(a4.data.y, a1.data.y, win.win, Nfft/2, Nfft, a1.data.fs);
  a9 = ao(fsdata(f, cxy));
  
  % Plot
  iplot(a8, a9, plist('YScales', 'lin', 'LineStyles', {'', '--'}))
  
end