h1 = sum(s1.hs .^ 2, 1); h2 = sum(s2.hs .^ 2, 1); [c,x] = cxcorr(h1,h2); figure hold on plot(h1,'r') plot(h2,'r') figure plot(x*6,c,'b')