i am trying to write a code to cross correlate a transmitted signal with a received signal to determine the number of samples delay

断了今生、忘了曾经 提交于 2019-12-10 21:35:43

问题


Cross correlation is to be used to measure distance to an aircraft by transmitting a known wide-band signal and correlating the transmitted signal with incoming signals received via the radar reception dish

The transmitted signal x(n) is of length N=512 while the received signal y(n) is of length N=2048.

y(n)=kx(n-d)+w(n); where 'kx(n-d)' is x(n) delayed by d samples and attenuated by a factor k, and w(n) is reception noise.

i am trying to write a MATLAB program to cross correlate x(n) with the y(n) to determine the value of d, the number of samples delay. And also Determine a suitable sampling frequency if the distance to the aircraft is to be determined within 50 km to an accuracy of 50 m, given that the transmitted and received data is travelling at the speed of light.


回答1:


The easiest way to do this is with the "xcorr" function. This is part of the Signal Processing toolbox for matlab, but should be available for GNU Octave here. I have not checked if the octave script is completely MATLAB compatible.

You can use the xcorr function as:

[correlation,lags] = xcorr(x,y);

The lag value can be found using

delay = lags(find(correlation==max(correlation)))

At the speed of light, the signal will be travelling at 3 x 10^8 m/s, so to have a resolution of 50m, you should be sampling at at least (3e8/50m) = 6MHz. At this sampling rate, each lag will be 1/6000000 second. If you multiply your delay by this value, you get your total time intervel between transmission and reception of the signal. Multiply this time intervel by the speed of light to get your distance.




回答2:


You can use generalized Cross correlation -Phase transform GCC PHAT The following is the MATLAB code for it

function time=GCCPHAT_testmode(b1,b2)

b1f=fft(b1);

b2f=fft(b2);

b2fc=conj(b2f);

neuma=(b1f).*(b2fc);

deno=abs((b1f).*(b2fc));

GPHAT=neuma./deno;

GPHATi=ifft(GPHAT);

[maxval ind]= max(GPHATi);

samp=ind

end



回答3:


we can ignore the 'find' function in matlab, the command could be changed to

delay = lags(correlation==max(correlation))

'xcorr' suits for vectors with long length;
'gcc' prefer frame by frame.




回答4:


Aj463's comment above is good, indeed GCC-PHAT is better than unweighted correlation for estimating delay of wide-band signals.

I would suggest a small improvement to the code posted above: to add a small value epsilon to the denominator, epsilon -> 0, in order to avoid eventual division by zero.

Thus, I would change the line

deno=abs((b1f).*(b2fc));

to

deno=abs((b1f).*(b2fc)) + epsilon; 


来源:https://stackoverflow.com/questions/7788005/i-am-trying-to-write-a-code-to-cross-correlate-a-transmitted-signal-with-a-recei

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!