EE-322L ADC Lab-3
EE-322L ADC Lab-3
Background
The correlation of a signal with itself is called the Autocorrelation. The Autocorrelation Ψ(τ )
of a real signal g(t) is defined as
Z ∞
Ψg (τ ) = (g(t)g(t + τ )) dτ ) (3.1)
−∞
It measures the similarity of a signal with itself. The Autocorrealtion provides valuable spectral
information which is helpful in analyzing the spectral energy density. The Energy Spectral
Density (ESD) is result of energies contributed by all the spectral components of the signal g(t)
i.e.
Ψg (f ) = |G(f )2 | (3.2)
An important relationship between the Autocorrelation of a signal g(t) and Energy Spectral
Density Ψg (τ ) exist that is the Energy Spectral Density(ESD) of a periodic signal is equal to
the Fourier Transform of Autocorrelation of the signal i.e.
Ψg (f ) = Ψg (τ ) (3.3)
Description
Consider the following Figure 3.1 of signal x(n) which shows a discrete time rectangular signal
with length N=5.
The magnitude of the Fourier Transform of this signal is given below
sin wN2
X(w) = (3.4)
sin w2
Plot the discrete time domain signal x(n) in Matlab using the following piece of code.
13
14 CHAPTER 3. AUTOCORRELATION AND ENERGY SPECTRAL DENSITY
The output graph produced should be similar to one in Figure 3.1. Using the signal x[n],
1.8
1.6
1.4
1.2
0.8
0.6
0.4
0.2
0
−5 −4 −3 −2 −1 0 1 2 3 4 5
find out the Autocorrelation y[n] of the signal by using the Matlab function xcorr(x,x). An im-
portant point to observe here is that the first sampling instant of Autocorrelation function y[n]
should be twice the first sampling instant of the signal x[n] itself. Same is true for the all the
points of the Autocorrelation function y[n] . Therefore, for writing the code for Autocorrelation
function y[n] we need to genrate the a timing vector twice that of the signal x[n] itself.
The Autocorrelation function y[n] should be similar to the Figure 3.2. In order to plot the
Fourier Transform F [n] of the Autocorrelation function y[n] the following piece of code is used.
15
0
−5 −4 −3 −2 −1 0 1 2 3 4 5
Listing 3.3: Plot for the Fourier Transform F(n) of the Autocorrelation Function y(n)
1 M=20;
2 k=−M/ 2 :M/ 2 ;
3 w=(2∗ p i /M) ∗k ;
4 Y=y ∗ ( exp (−2∗ i ∗ p i /M) ) . ˆ ( ny ’ ∗ k ) ;
5 stem (w,Y)
6 a x i s ([ −4 4 0 3 0 ] )
After plotting the Fourier Transform F [n] of the Autocorrelation Function y[n], find out
the Energy Spectral Density E[n] of the signal x[n] using its Fourier Transform. The Energy
Spectral Density E[n] of a signal is the magnitude square of its Fourier Transform. The following
piece of code finds out the Energy Spectral Density E[n].
Listing 3.4: Plot for Energy Spectral Density E(n) of the signal x(n)
1 N=5;
2 M=20;
3 i =1;
4 f o r k=−M/ 2 :M/2
5 w=(2∗ p i /M) ∗k ;
6 i f k==0
7 $ X( i )=N; $}
8 else
9 $X( i )=s i n (w∗N/ 2 ) / s i n (w/ 2 ) ; $}
10 end
11 i=i +1;
12 end
13 ESD=(abs (X) ) . ˆ 2 ;
14 w=(2∗ p i /M) ∗[−M/ 2 :M/ 2 ] ;
15 stem (w, ESD)
16 CHAPTER 3. AUTOCORRELATION AND ENERGY SPECTRAL DENSITY
30
25
20
15
10
0
−4 −3 −2 −1 0 1 2 3 4
16 a x i s ([ −4 4 0 3 0 ] )
17 t i t l e ( ’ESD o f Actual S i g n a l ’ )
Figure 3.3 representing the Fourier Transform F [n] of the Autocorrelation Function y[n]
and Energy Spectral Density E[n] of the signal x[n] represented by Figure 3.4 are similar to
each other thus showing that the Energy Spectral Density(ESD) of a periodic signal is equal
to the Fourier Transform of Autocorrelation of the signal. Plot all the figures on the same
window using the subplot command for the ease of comparison. Vary the period and range of
the sampling points separately to observe their effects in Matlab.
Listing 3.5: Plot for both the figures on the same window
1 n=[ −2:1:2];
2 x=[1 ,1 ,1 ,1 ,1];
3 figure (1) ;
4 stem ( n , x )
5 a x i s ([ −3 3 0 1 . 5 ] ) ;
6 t i t l e ( ’ Gate Function ’ ) ;
7 y=x c o r r ( x , x ) ;
8 ny = [ − 4 : 1 : 4 ] ;
9 figure (2) ;
10 stem ( ny , y )
11 a x i s ([ −5 5 0 6 ] ) ;
12 t i t l e ( ’ Auto C o r r e l a t i o n ’ ) ;
13 M=20;
14 k=−M/ 2 :M/ 2 ;
15 w=(2∗ p i /M) ∗k ;
16 Y=y ∗ ( exp (−2∗ j ∗ p i /M) ) . ˆ ( ny ’ ∗ k ) ;
17 f i g u r e ( 3 ) ;
17
25
20
15
10
0
−4 −3 −2 −1 0 1 2 3 4
18 stem (w,Y)
19 t i t l e ( ’ Energy S p e c t r a l D e n s i t y ’ ) ;
Assignment