Вы находитесь на странице: 1из 4

M513 Advanced DSP Techniques Laboratory Exercise 5

M513 Advanced DSP Techniques Laboratory Exercise 5

Exercise 5

Autocorrelation and Cross-Correlation


This exercise covers some simple applications of autocorrelation and cross-correlation operations on periodic and random type signals and demonstrates some properties of those functions. Estimating delay in echoed signal In this example you will simulate a simple acoustic problem shown in figure below. Hard reflector

Task 2: Calculate the autocorrelation of received signal x. Set the maximum lag of the autocorrelation function to 2.5 s (i.e. autocorrelation should be calculated for the interval -2.5 s 2.5 s). Plot the signal x and its autocorrelation sequence and notice the peak values in the sequence. Where do they occur? Hint: You can use Matlab function xcorr to calculate autocorrelation of sequence x. Type help xcorr in the command window to learn more about this function. Task 3: Generate additive noise using noise=a*std(s)*randn(size(x)) and add it to received signal x. Run the same simulation for this noisy case, i.e. calculate autocorrelation using noisy signal x. Plot the signal x and obtained autocorrelation again. Comment on these issues: 1. What is noisier your signals or new autocorrelation sequence? 2. Can you still detect the peaks and corresponding delays in the autocorrelation sequence obtained from the noisy signals? 3. How do you explain this?

Path 2, delay 2

Source, s(t)

Path 1, delay 1

Microphone, x(t)

Following the reflection of the sound from the hard reflecting surface, the signal at the microphone can be written as: x ( t ) = a s ( t 1 ) + b s ( t 2 ) The system to simulate has the following parameters: sampling rate fs = 200 Hz path 1 delay, 1 = 1 s path 2 delay, 2 = 2.5 s relative amplitudes of two waveforms - a=2, b=1 Task 1: Generate a 0.5 seconds sine burst signal s(t) with frequency of 10 Hz. Delay this signal appropriately to generate two signals in Matlab: s1 ( t ) = a s ( t 1 ) and
s2 ( t ) = a s ( t 2 ) . Those signals should be 4 s long. Now, combine/add those two signals

to make the signal x(t). Hint: to delay sine burst by 1 and generate signal s1, you can use the following Matlab commands:
N=4*fs; % ensure 4 s long signals, s1=[zeros(1,delta1*fs) a*s]; % fs and delta1 should be defined earlier in the script s1=[s1 zeros(1,N-length(s1))]; 1
BV October, 2011 BV October, 2011

M513 Advanced DSP Techniques Laboratory Exercise 5

M513 Advanced DSP Techniques Laboratory Exercise 5

Use of cross-correlation in radar system

To maximise the detectability a special filter called matched filter can be used in this kind of situations. The matched filter is proven to be optimal detector while maximising the SNR of a signal that is buried in noise. If the length of the emitted signal is T seconds, the impulse response of the matched filter is defined with:
h ( t ) = x (T t )

i.e. the signal x(t) is time-reversed (x(-t)) and time-shifted (x(T-t)) to obtain the impulse response of matched filter. Matched filtering is symbolically shown on figure below for both analogue and discrete-time domains.

y(t) input

ym(t)

h(t)=x(T-t)

output

y(n) input

ym(n)

h(n)=x(N-n)

output

This example demonstrates the basic concept of using cross-correlation operation in a simple radar-like system. Radar systems in general estimate the distance to the target by emitting a pulse type signal and measuring the time elapsed between the signal transmission and reception. In this example we will use a chirp type signal, commonly used in radar and sonar type systems instead of simple pulse and show how cross-correlation improves the signal-tonoise ration and enables easy measurement of signal delay. A chirp signal is a sinusoid with a frequency that changes continuously over a certain frequency band over a certain period of time. For emitted signal x(t), received signal y(t) can be expressed as:
y ( t ) = ax ( t ) + n ( t )

Task 4: Prove that the output of matched filter actually represents the cross-correlation between emitted signal x(t) and received signal y(t), i.e. prove this mathematical relation: ym ( t ) =

y ( ) h ( t ) d = y ( ) x (T ( t ) ) d = ... = R (T t ) = R ( t T )
yx xy

This is a pen and paper exercise. You can attempt your proof in either analogue or discrete domains. Task 5: Also prove that the cross-correlation function Rxy() in this situation equals scaled and time-shifted autocorrelation function of the emitted signal, i.e. prove the, relation: Rxy ( ) = E x ( t ) ( ax ( t + ) + n ( t ) ) = ... = aRxx ( ) (You can assume zero-mean values for all signals in the system.) Using two derived relations, the matched filter output can therefore be expressed as:
ym ( t ) = Rxy ( t T ) = a Rxx ( T ) = a Rxx ( (T + ) )
4
BV October, 2011

where n(t) represents the uncorrelated broadband noise and a is the relative amplitude of the reflected waveform. Main problem in delay estimation for radar systems is that the amplitude of the reflected signal may be very small compared to the original signal and the amount of noise present in the signal. The SNR of the received signal y(t) is therefore usually very low.
3
BV October, 2011

M513 Advanced DSP Techniques Laboratory Exercise 5

M513 Advanced DSP Techniques Laboratory Exercise 5

Since (according to above equation) cross-correlation function gives total time delay between the transmitter and the receiver in the system, the distance to the target can now be easily estimated by multiplying the half of the time delay, /2 with the speed of the wave. Task 6: Write a Matlab code to simulate signal in described system. Your code should generate both emitted and received signals and obtain the cross-correlation in two different ways directly (using xcorr function in Matlab) and indirectly, by designing the matched filter and then filtering the received signal through this filter. The system to simulate should have the following parameters: sampling rate, fs = 200 Hz reflected waveform delay =2 s relative amplitude of the reflected waveform: a=0.1 duration of the received signal 6 s Hints: The emitted signals should be chirp type signal. This signal is a sine-wave like signal but with linearly increasing frequency. For our simulation, the starting frequency of the chirp signal should be 5 Hz (at 0s) and the final frequency at the end of the burst should be 15 Hz (at 1s). This signal is easily generated in Matlab using the following sequence of instructions:
t=0:1/fs:1; x=chirp(t,5,1,15);

Notice how cross-correlation operation maximises the SNR of the signal deeply buried in the noise and enables easy determination of the system delay. Estimate this delay from the plots for Rxy(t) and ym(t). Comment on this issue: Why is there a difference in delay estimated by those two methods? (i.e. What is this difference equal to?)

By flipping this signal in the left-right direction, the impulse response of the matched filter can be obtained:
h=fliplr(x);

Once you have generated the reflected signal y(t) by delaying the transmitted signal by the appropriate amount of time (as you have already done with the signals in the first part of this exercise), you should also add a significant amount of noise to this signal. Matlab command:
noise=2*std(a*x)*randn(size(y));

can be used to generate noise which should than be added to the received/reflected signal. This will provide a very low SNR of -6 dB. Task 7: Plot all important waveforms in this example: a) Transmitted chirp signal - x(t) b) Matched filter impulse response - h(t) c) Received signal (deeply buried in the noise) - y(t) d) Cross-correlation sequence (directly obtained) - Rxy(t) e) Output of the matched filter - ym(t)
5
BV October, 2011 BV October, 2011

M513 Advanced DSP Techniques Laboratory Exercise 5

Cross-correlation in system estimation tasks It has been demonstrated in the lecture how cross-correlation between the system input and output can be used to estimate system impulse response. The approach is demonstrated in the figure below.

x(n)

y(n)

h(n)

For the white noise type input x(n), the impulse response of the system can be estimated using: Rxy ( m ) h ( m) = x2 Task 8: Prove this by writing a Matlab script that will do the following: 1. Design a band pass IIR type filter using the following set of instructions:
Fs = 8000; % sampling frequency fcl = 300; % lower cut-off frequency fch = 500; % higher cut-off frequency norder = 2; % filter order [b,a] = butter(norder,[fcl/(Fs/2) fch/(Fs/2)]);

2. 3. 4. 5. 6.

Obtain impulse response of this filter and plot it. Generate a white noise sequence x(n). Pass this sequence through the designed filter (unknown system) to obtain y(n). Obtain cross-correlation between the filter output and input - Rxy(m). Use calculated cross-correlation to estimate the impulse response of the filter according to the above relation.

Note that since the input is white noise, i.e. random, the experiment will not be valid for single run of the script, the filtering should therefore be carried for a number of times and the final result obtained as the average of all runs.

7
BV October, 2011

Вам также может понравиться