need help with cross correlation output. not out putting the correct position.

2 views (last 30 days)
Hello, I have a cross correlation code written that uses findpeaks to locate positions of the high correlated signals in the waveform. My problem is when I plot my EQ output my results are completely random (visually where the highly correlated signals (very obviously seen) are not aligned. Where did I go wrong? Manually checking is not always an option since this is a piece of a much larger code where I have several hundreds 'D' data and thousands of 'T' templates to cross correlate.
D= DATA(1x360000)
T=D(2001:5000); %some small signal
nt1=length(T);
for i= nt1:(nt-nt1)
cc(i)=(max(xcorr(T,D(i:i+nt1-1), 1, 'coeff')));
end
[pks,loc]=findpeaks(cc,'MinPeakDistance',300,'MinPeakHeight',.5);
clear EQ
count=0;
for eqpk=(1:length(loc))
count=count+1;
EQ{count}=D((loc(eqpk)-100: loc(eqpk)+200));
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!