% multicomponent FIGURE for SP paper
% Steve Mann,                                1992 jul 21
%
% SEE BOTH:    figs/LEM  figs/BCT   for related things
%
% does 3 component bowtie:  time--domain plot,  TF,  bowtie_ab,  bowtie_beg_end
%
% To run the old clt.m script, i need once to do:
% matlabpath([getenv('MATLABPATH') ':/u/steve/TFaffine/chirplet'])

disp('SETTING MATLABPATH for some strange reason, chirp doesnt get in there')

matlabpath('/u/steve:/u/steve/chirp:/u/steve/TFaffine/chirplet:/u/steve/tf:u/steve/chirp:/u/steve/matimg:/u/steve/matc:/u/steve/wavelet:/u/steve/wave:/u/steve/slepian:/u/steve/reform:/u/steve/mallat:/u/steve/mallat/mallat2:/u/steve/linearalgebra:/u/steve/hyper:/u/steve/hos:/u/steve/gabor:/u/steve/matdat:/mas/lib/ds/matlab/toolbox/local:/mas/lib/ds/matlab/toolbox/matlab:/mas/lib/ds/matlab/toolbox/demo:/mas/lib/ds/matlab/toolbox/signal:/mas/lib/ds/matlab/toolbox/terminal')


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

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

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

  disp('put time domain signal in ``s''''')
  s = x1 + x2 + x3;
  contour(abs(tf(s,80,80)))
  grid

  disp('computing clt a b')
  fix(clock)
%%  cltab = clt_ab(s,.5,.5,M);
  cltab = clt_ab(s,length(s)/4,length(s)/4,M);
  fix(clock)
  
  disp('computing clt beg end')
  fix(clock)
  cltbegend = clt(s,.5,M);
  fix(clock)

%  save multicomponentideal
%  save deleteme

else%if S already present, contour it

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

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

  title('Adapted Chirplets in Bowtie-Chirplet Space')
  xlabel('Beginning Frequency')
  ylabel('Ending Frequency')
  grid

end%if ~exist S

