How can I find cross-correlation between two signals?
Show older comments
Hello. :)
I heard that there are a lot of geniuses here. help me :(
I have a couple of question about my algorithm.
I want find similarity between two signal.
I generate two simple signal(temp, temp2)
I want find a similar signal between "red" signal and "blue" signal
So, I used xcorr fuction in matlab.
I used xcorr(red,blue) command in matlab.

Because red signal shape is similar to "1st Peak" at blue signal in image(attached image)
So the algorithm shoud find have found "1st peak" .
But my source was find always "2 peak" at blue line in image(attached image).
I was worried enough... But I can not find solution!
The problem is I think "2 peak" value amplutude is bigger than "1peak".
I think the result of convoultion(cross-correlation) value is big at 2peak....!
what should i do?
*I want find that where is the most similar signal. like X-axis value*
(I wnat to find "1 peak in blue lin")
The red signal time shifted just 10 times. not 110 times....
*The answer is 10!! :(*
Should I use Threshold? is it good algorithm? This case is very simple but if I solve the this problem, I'll apply this algorithm to complex signal.
here is my code
I just ask idea(like think, algorithm...) Not overall source code rivision.
2013.10.24 (10:36)
I tried command "corrcoeff".
But the R value is same between '1 peak' and '2 peak' as "1" value.
How can I classifiate these signl?
Have a good day!!
#####generate signal########
t3 = 1:0.01:1.5;
scanline4 = sin(2*pi*t3);
temp = [scanline4];
temp2 = [[zeros(1,10) scanline4 2*scanline4]];
windo = 50;
repe =1;
sector = 1;
count = 1;
for targetPt = 1:1 : length(temp)
if (targetPt >= length(temp)-windo), break,end ;
maxcorr = -10;
for i = 1:repe:length(temp2)
if (i >= length(temp2)-windo), break,end ;
[correlation,lags] = xcorr(temp(targetPt:targetPt+windo),temp2(i:i+windo));
c = xcorr(temp(targetPt:targetPt+windo),temp2(i:i+windo));
maxV(count)= max(correlation);
if maxcorr < maxV(count)
maxcorr = maxV(count);
index = i
end
count = count +1;
end
delaymatrix(sector,1) = index-targetPt;
sector = sector+1;
end;
1 Comment
Ramesh Bala
on 15 Feb 2019
Strange that no reply here !!
This is the syntex for cross correlation
crosscorr(y1,y2)
crosscorr(y1,y2,Name,Value)
xcf = crosscorr(___)
[xcf,lags,bounds] = crosscorr(___)
crosscorr(ax,___)
[xcf,lags,bounds,h] = crosscorr(___)
Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!