
0053 scores = zeros(length(testoff),N);   offsets = zeros(N,1);
0054 <span class="keyword">for</span> n = 1:N
0055     <span class="keyword">for</span> off = 1:length(testoff)
0056         temp = templateShift(off,:,:);  test = waveforms(n,valid,:);
0057         scores(off,n) = sum((temp(:) - test(:)).^2);
0058     <span class="keyword">end</span>
0059     p = Q * scores(:,n);
0060     offsets(n) = -p(2)/(2*p(1));
0061 <span class="keyword">end</span>
0062 
0063 offsets = -offsets;   <span class="comment">