% test multicomponent signal
% 1992 jul 21 .. . need next line to do once 
% matlabpath([getenv('MATLABPATH') ':/u/steve/TFaffine/chirplet'])

if ~exist('S')  % if S is not present, generate it
% M = 200 for thesis, set smaller for fast run 92jul21
M = 200;   % size of CLT (square)

  % K = 512 for thesis; smaller for fast run 92jul21
  K = 512;   % number of points in each chirp

  x1 = chirp(.05,.3,K).';
  x2 = chirp(.29,.36,K).';
  x3 = chirp(-.15,-.33,K).';

  s = x1 + x2 + x3;
  % axis([0 512 -.0149 .0149])
  axis('normal')
  plot(linspace(0,1,length(s)), 10* real(s.*gauss(512,75).'))
  title('Real part of time domain signal')
  xlabel('Time')
  ylabel('Signal amplitude')
  grid

  TFs = abs(tf(s.*gauss(512,75).',128,128));  % window TF as well as BCT
  disp('now TFs contains the magnitude of the TF for variable s')
  contour(TFs)
  grid

  fix(clock)
  S = clt(s,.5,M);
  fix(clock)

  disp('replacing S with its absolute (magnitude) value')
  S = abs(S);
  disp('now variable S contains the multicomponent ideal BCT of 3 chirplets')

  disp('about to save results in ``multicomponentideal''''')
  save multicomponentideal
%  save deleteme

else%if S already present, contour it

  X = linspace(-.5,.5,M);
  Y = linspace(-.5,.5,M);

  axis('square')
  contour(abs(S),[5 7 9 10 11 12 13 14 14.5],X,Y)

  title('Frequency-frequency (FF) transform of three chirplets')
  xlabel('Beginning Frequency')
  ylabel('Ending Frequency')
  grid

end%if ~exist S

