cross correlation and autocorrelation on matlab
DESCRIPTION
Signals and linear systemTRANSCRIPT
SIGNAL AND LINEAR SYSTEMS ASSIGNMENT CROSS CORRELATION AND AUTOCORRELATION ON MATLAB A radar altimeter measures the altitude of a target above the terrain. They are often pulse –radars which transmit short microwave pulses and measure the round trip time delay to determine the distance between the target and the ground. MOHAMAD MUDDASSIR GHOORUN 6/29/2012
2
TABLE OF CONTENTS:
1. INTRODUCTION
Q1. Generating a pulse signal x (n), the transmitted pulse from the radar.
Q2. Generating delayed and attenuated signal, xd(n)
Q3.Generating Gaussian random noise, w (n)
Q4.Generating received signal by adding noise with transmitted signal
Q5. Estimating cross correlation sequence Rrx(m) and the delay
2. DISCUSSION
3. CONCLUSION
4. REFERENCES
3
LIST OF FIGURES:
Figure 1: Pulse Radar
Figure 2: Transmitted pulse x (n)
Figure 3: Pulse signal xd(n) both delayed by N=32 and attenuated by α = 0.7
Figure 4: N=256 samples of gaussian random signal representing noise , w(n)
Figure 5: Received signal r (n) obtained by adding delayed & attenuated signal with noise
Figure 6: Cross correlation of transmitted signal with respect to received signal
Figure 7: Zoomed in graph of figure 6.
Figure 8: Cross correlation graph of same signals using α=0.6.
Figure 9: Cross correlation graph of same signals using α=0.5.
4
1.0 INTRODUCTION
Correlation is nothing but the degree of similarity a signal is with respect to another signal.
If the signals are identical, then the correlation coefficient is 1, and if it is totally different it
is then 0. In such a case whereby the signal is 180 degrees out of phase with the reference
or compared signal, the correlation coefficient is -1. When two independent signals are
compared, the procedure is known as “cross correlation” and when the signal is compared
to itself, it is then known as “autocorrelation”.
In relation to this assignment, the concepts of cross correlation and autocorrelation
are used in the application related to a radar altimeter which is used to measure the distance
the distance between the target and the ground as shown in figure 1.
Figure 1: Pulse radar
As shown above, a pulse x(t) is transmitted from the transmitter of the radar and the
reflected signal from the target is received back by the radar receiver. The received signal
r(t) which is now delayed, attenuated, and added with noise is a form of the original
transmitted signal, x(t), is then analyzed to estimate the time delay between the transmitted
and received signal.
5
Q1. To generate the pulse signal x(n) representing the transmitted pulse from the
radar.
%-----------------------------------------------------------------------------------------%----------------
% PULSE SIGNAL REPRESENTING TRANSMITTED PULSE FROM RADAR
%-----------------------------------------------------------------------------------------%----------------
N=256; %Number of samples
n=-96:160; % Range (start: end)
x=[zeros(1,97),ones(1,4),zeros(1,156)]; % The signal properties as shown in fig 2
y=5*x; % Amplitude set as 5
plot(n,y); %Plotting n versus y
grid; %Grid lines to be included in figure 2
Figure 2: Transmitted pulse x (n)
6
Q2. To generate a delayed signal xd(n) by delaying transmitted signal by N=32
samples and reducing its amplitude by an attenuation factor of α = 0.7.
%---------------------------------------------------------------------------------------------------------
%DELAYED AND ATTENUATED SIGNAL Xd(n) representing the delayed transmitted
% signal from the radar
%---------------------------------------------------------------------------------------------------------
N=256; %Number of samples
n=-96:160; % Range from -96 to 160
a=[zeros(1,(N/2)+1),ones(1,(N/2))];
b=5*a; %Amplitude made to be 5
%plot(n,b);
grid;
u=[zeros(1,(N/2)+5),ones(1,(N/2)-4)];
r=5*u; % Amplitude made to be 5
%plot(n,r);
grid;
f=0.7*(b-r); % Delayed signal being multiplied by attenuation
%factor of 0.7
plot(n,f); %Plotting n versus f
grid; %Inserting grid lines on graph
title('Pulse signal xd(n) representing delayed and attenuated signal'); % Title of graph
xlabel('sample number'); %Labeling the x-axis
ylabel('Amplitude'); %Labeling the y-axis
The above codes were tested on matlab and are shown down in figure 3 satisfying both the
attenuation factor α =0.7 and delayed by N=32.
7
Figure 3: Pulse signal xd(n) both delayed by N=32 and attenuated by α = 0.7
Q3. Generate N=256 samples of Gaussian random signal representing the noise w(n)
N=256; % Number of samples
n=-96:160; % Range of N values
R1=randn(1,N+1); % Generate Normal Random Numbers
%subplot(2,2,1); % Subdivide the figure into 4 quadrants
plot(n,R1); % Plot R1 in the first quadrant
grid; % Inserting gridlines on graph
The above codes have been tested on Matlab and the graph is available on figure 4 as
shown below.
8
Figure 4: N=256 samples of gaussian random signal representing noise , w(n)
Q4. Generate the received signal by adding the noise signal, w(n) with the transmitted
signal
xx=R1+f; %Adding noise signal to delayed and attenuated signal
plot(n,xx); %Plotting received signal against n values
grid; %Inserting gridlines on the graph
title('Normal [Gaussian] Distributed Random Signal added with delayed and attenuated
signal'); %Title of graph
xlabel('Sample Number'); %Labeling the x-axis
ylabel('Amplitude'); %Labeling the y-axis
The simulation of the above codes on matlab produced the results which can be viewed at
figure 5.
9
Figure 5: Received signal r(n) obtained by adding delayed & attenuated signal with noise
Q5. Estimate the cross correlation sequence Rrx(m) and estimate the delay.
[C,LAGS]= xcorr(xx,x);
% C is cross correlation sequence
% Lags is a vector of the lag indices at which c was
%estimated
% xx and x are the two signals to be correlated
plot(LAGS,C); %Plotting C versus the lag
title('Cross correlation of transmitted signal and received signal');
% Title of graph
grid; %Inserting gridlines on the graph
10
Figure 6: Cross correlation of transmitted signal with respect to received signal
As seen above the cross correlation of the transmitted signal with respect to the received
signal has a peak at 32 which is exactly the delay we gave to the transmitted signal in Q2.
Figure 6 has been zoomed in for us to be able to view the delay more precisely as displayed
in figure 7. Therefore, we can see that the simulated result agrees with the theoretical value.
Other factors which can influence the cross correlation graph such as α and N are discussed
in the discussion part below.
11
Figure 7: Zoomed in graph of Figure 6
12
2. DISCUSSION:
The value of α, the attenuation factor usually affects the amplitude of the cross correlation
graph of the 2 signals. As shown above in figure 7, α=0.7 and amplitude of graph is 13.55.
When α is made to be 0.6, as shown from figure 8, the amplitude drops to 11.3 and when
α=0.5, amplitude further drops to 9.15 as shown in figure 9.
Figure 8: Cross correlation graph of same signals using α=0.6.
Figure 9: Cross correlation of same signals using α=0.5.
13
Having seen the effect of changing the alpha values gave us same graph with same length
and delay but with different amplitudes, we will now analyze how the value of N affects
cross correlation. However in contrast to the alpha value, when changing the value of N,
which is the length of the signal, the graph had no real change except that the length of the
signal was changed to the new value of N. The amplitude and delay stayed the same.
Therefore we can say that for a signal, the graph will be unchanged in terms of amplitude or
delay even if we change the value of N.
3. CONCLUSION:
From this assignment, it was foUnd that one way to measure the distance to an object is to
transmit a short pulse of radio signal (electromagnetic radiation) and measure the time it
takes for the reflection to return which is the time delay which is obtained by using cross
correlation. The distance is one-half the product of the round trip time because the signal
has to travel to the target and then back to the receiver and the speed of the signal. Having
already the speed of light, c= (3.0*10^8) m/s and the time taken for the signal to come
back, it is easy to calculate the distance of the target using the formula speed =
distance/time. However, since radio waves travel at the speed of light, accurate distance
measurement will be done by using of high-performance electronics in the industry. Having
completed this assignment, other things learnt was that correlation is not only used to
measure distance for radar altimeters but instead has other applications like fluorescent
correlation spectroscopy (FCS) where fluctuation of fluorescence intensity is analyzed and
molecular complexing amongst many others in the industry.
14
REFERENCES:
Gibbon, D., 1996, Correlation: cross correlation and auto correlation
[online], available from:
http://coral.lili.unibielefeld.de/Classes/Summer96/Acoustic/acoustic2/node18.
html
Staffordshire University, Signal analysis using matlab [online], available
from:
http://www.fcet.staffs.ac.uk/alg1/2004_5/Semester_1/Signal%20Processing,%
20SP%20(CE00039-2)/LABS/LAB3.pdf
Cheung, P., 2010, Signals and linear systems [online], Imperial college
London, available from:
http://www.ee.ic.ac.uk/pcheung/teaching/ee2_signals/Lecture%201%20-
%20Introduction%20to%20Signals.pdf
Taghizadeh, S.R, 2000, Discrete time signals & case studies, Digital signal
processing [online], (Part 3), Page 36
Babu, R., 2011, Signals and systems, 4th
edition,Scitech Publications India Pvt
Lt