%
%  this routine slides a template across eeg signals and looks for 
%     matches
%
%  template is the template we are to use
%  signal is the signal we are comparing the template to
%
function cc = laptop7(template,name,start)
%
%  load the signal file
%
  signal = load(name);
  signal = signal(start:end);
%
%  get the length of the signal and the length of the template
%
  Nt = length(template)-1;
  Ns = length(signal);
%
  for k = 1:Ns-Nt
        num = sum(template.*signal(k:Nt+k));
%
%       use the following two denominators for template matching
%
        den1 = 
        den2 = ;
%
        cc = num/(den1*den2);
  end;
%
%  set the sampling rate
%
  fs = 100;
%
  tt = [0:length(signal)-1]/fs;
  figure; orient tall;
  subplot(3,1,1); plot([0:Nt]/fs,template); grid; axis([0 max(tt) min(signal) max(signal)]);
  xlabel('Time (sec)'); ylabel('Template x(n)');
    title([' Template Matching using file ' name ', starting at ' , num2str(start)]);
  subplot(3,1,2); plot(tt,signal); grid; xlabel('Time (sec)'); ylabel('Signal y(n)'); axis('tight');
  subplot(3,1,3);plot([0:Ns-Nt-1]/fs,cc); grid; axis([0 max(tt) -1 1]);
     ylabel('Correlation Coefficient ');
     xlabel('Time (seconds)');
   
  
