|
From: signal on 29 Jun 2005 14:03 Hi expert, I used xcorr to calculate cross correlation in matlab, i tried to do the same thing by using fft, so : i have 2 signals x, y L=max(lenght(x), lenght(y)) xx=fft(x,2*L). yy=fft(y,2*L). Sxy=xx.*conj(y); rxy=fftshift(real(ifft(Sxy))) ; Rxy is my cross correlation,the problem is when i drawed rxy and xcorr(x,y) i dont find equality between rxy et xcorr, where is the problem Thanks a lot to answer at my question. This message was sent using the Comp.DSP web interface on www.DSPRelated.com
From: Rune Allnor on 30 Jun 2005 03:57 I don't have xcorr available, so I don't know the detail of how it works, but here are some suggestions of what to look for. > I used xcorr to calculate cross correlation in matlab, i tried to do the > same thing by using fft, so : > i have 2 signals x, y > L=max(lenght(x), lenght(y)) Make sure to use the signal the same length as xcorr does. I wouldn't be surprised if it is something along the lines of L=length(x)+2*(length(y)-1); > xx=fft(x,2*L). > yy=fft(y,2*L). Make sure to use the same FFT length as xcorr does. Again, I wouldn't be surprised if it is something along the lines of Nfft = length(x)+2*(length(y)-1); Remember, no symmetry can be expected for cross correlation. > Sxy=xx.*conj(y); Could it be that the order of the conjugates are different? > rxy=fftshift(real(ifft(Sxy))) ; Does xcorr shift the data so that zero lag ends up in the middle? If so, how does it handle the different lengths of x and y? > Rxy is my cross correlation,the problem is when i drawed rxy and > xcorr(x,y) Rune
From: Martin Eisenberg on 30 Jun 2005 09:36 signal wrote: > Sxy=xx.*conj(y); Sxy=xx.*conj(yy);
From: Jim Thomas on 30 Jun 2005 09:47 signal wrote: > Sxy=xx.*conj(y); Should that be Sxy=xx.*conj(yy); ?? -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas(a)bittware.com http://www.bittware.com (603) 226-0404 x536 Any sufficiently advanced technology is indistinguishable from magic. - Arthur C. Clarke
From: signal on 30 Jun 2005 10:09
Hi, thanks for your response. This is a typing error, i used sxy=xx.*conj(yy). >signal wrote: >> Sxy=xx.*conj(y); > >Should that be Sxy=xx.*conj(yy); > >?? > >-- >Jim Thomas Principal Applications Engineer Bittware, Inc >jthomas(a)bittware.com http://www.bittware.com (603) 226-0404 x536 >Any sufficiently advanced technology is indistinguishable from magic. > - Arthur C. Clarke > This message was sent using the Comp.DSP web interface on www.DSPRelated.com |