You are on page 1of 7

1

American International University-Bangladesh


Department of Electrical and Electronic Engineering
Digital Signal Processing


Experiment no. 01(Final Term): Discrete Time Fourier Transform


Objective:

- To learn how to compute and interpret the Discrete Time Fourier Transform (DTFT) of a
discrete signal
- To investigate the properties of DTFT


Introduction:

If x(n) is absolutely summable, this is ,
[ ]

=
<
n
n x ) (
, then its DTFT is given by

[ ]

=
n
n j j
e n x e X

) ( ) (

The inverse Discrete Time Fourier Transform (IDFT) is defined as

d e e X n x
n j j
) (
2
1
) (

The DTFT transforms a discrete signal x(n) into a complex valued continuous functions X(e
jw
) of
a real vaiarble w, called a digital frequency , which is measured in radians.

Example 1: Determine the DTFT of the following discrete signal

) ( ) 5 . 0 ( ) ( n u n x
n
=

Solution: The sequence x(n) is absolutely summable; therefore its DTFT exists. The DTFT of
x(n) is defined as

n j n
n
n j j
e e n x e X


=


= =
0
) 5 . 0 ( ) ( ) (


2

) ........( .......... ) 5 . 0 ( ) 5 . 0 ( 1 ) 5 . 0 ( ) (
2
0
A e e e e X
j j n j j
+ + + = =



Multiplying both side of Equation (A) by
i
e

5 . 0
, we got the following


) ........( .......... ) 5 . 0 ( ) 5 . 0 ( ) 5 . 0 ( ) 5 . 0 )( (
3 2
B e e e e e X
j j j j j
+ + =

Subtracting Equation (B) from Equation (A), we can find the DTFT of x(n) is

5 . 0 5 . 0 1
1
) (

j
j
j
j
e
e
e
e X


The following MatLab code will compute the DTFT of x(n)










In this example the the DTFT of x(n) has been found for 501 equispaced points between [ 0, ]. Please
examine the plots produced by the above piece of Matlab Code.

w = [0:1:500]*pi/500; % [0, pi] axis divided into 501
% points.
X = exp(j*w) ./ (exp(j*w)-0.5*ones(1,501));
magX = abs(X); angX = angle(X);
realX = real(X); imagX = imag(X);
subplot(2,2,1); plot(w/pi, magX); grid
xlabel('frequency in pi units'); ylabel('Magnitude'); title('Magnitude Part');
subplot(2,2,2); plot(w/pi, angX); grid
xlabel('frequency in pi units'); ylabel('Radians'); title('Angle Part');
subplot(2,2,3); plot(w/pi, realX); grid
xlabel('frequency in pi units'); ylabel('Real Value'); title('Real Part');
subplot(2,2,4); plot(w/pi, imagX); grid
xlabel('frequency in pi units'); ylabel('Imaginary Value'); title('Imaginary Part');

3
Example 2: Find the DTFT of the signal defined by
n
j n x )) 3 / exp( 9 . 0 ( ) ( =

where 0 n10.

Solution: The DTFT of the x(n) is defined as

=

=

= = =
10
0
) 3 / (
10
0
3 /
) 9 . 0 ( ) 9 . 0 ( ) ( ) (
n
n w j n j
n
n j
n
n j j
e e e e n x e X


The following piece of MatlabCode will compute the DTFT of x(n) and plot it.








Another alternative implementation of the code is shown as follows:









n = 0:10; x = (0.9*exp(j*pi/3)).^n;
k = -200:200;
w =(pi/100)*k;
X = x*(exp(-j*pi/100)).^(n'*k);
magX = abs(X); angX = angle(X);
subplot(2,1,1); plot(w/pi, magX);
grid
xlabel('frequency in pi units');
ylabel('Magnitude');
title('Magnitude Part');
subplot(2,1,2);
plot(w/pi, angX/pi);
grid
xlabel('frequency in pi units');
ylabel('Radians/pi');
title('Angle Part');
k = -200:200;
w =(pi/100)*k;
X=0.0

for n=0:10
X=X+(0.9*exp(j*pi/3-j*w)).^n

end

magX = abs(X); angX = angle(X);
subplot(2,1,1); plot(w/pi, magX);
grid
xlabel('frequency in pi units');
ylabel('Magnitude');
title('Magnitude Part');
subplot(2,1,2);
plot(w/pi, angX/pi);
grid
xlabel('frequency in pi units');
ylabel('Radians/pi');
title('Angle Part');

4
Some of the important properties of the DTFT are as follows:
1. Periodicity : The Discrete Time Fourier Transform (DTFT) of a signal x(n) is periodic in
with a period of 2.
) 2 (
( ) (
+
=
j j
e X e X

2. Symmetry: For a real valued signal x(n) , its DTFT
) (
j
e X
is a conjugate symmetric

) ( ) (
* j j
e X e X =

3. Linearity: The DTFT is a linear transformation; that is ;

If
) ( ) (
1 1
j
e X n x

) ( ) (
2 2
j
e X n x

Then

) ( ) ( ) ( ) (
2 1 2 1


j j
e X e X n x n x + +

4. Time Shifting : A shift in the time domain corresponds to the phase shifting

k j j
e e X k n x

) ( ) (

5. Frequency Shifting: Multiplication by a complex exponential corresponds to a shift in the frequency
domain.

) ( ) (
) (
0 0

j n j
e X e n x

The students can easily verify the periodicity property and symmetry property from Example 1 and
Example 2. We will now verify linearity property, time shifting property and frequency shifting property.

Example2: In this example we will verify the linearity property using real-valued finite duration
sequences. Let x
1
(n ) and x
2
(n) be two random sequences uniformly distributed between

5
[0,1] over 0n10. By using the following piece of MatLab code we can verify the
linearity property of DTFT.















Example 3: To verify the time shifting property , we generate a random sequence uniformly
distributed between [0,1] over 0 n10 and we will generate another signal y(n)=x(n-2).
Then we will verify the sample shift property. Use the following piece of MatLab code







x1=rand(1,11); % generate random number x1
x2=rand(1,11); % generate random number x2
alpha=2;
beta=3;
x3=alpha*x1+beta*x2 % generate the third signal and x3 is a
linear combintaion
% of x1 and x2

% compute the DTFT of x1,x2 and x3
n=0:10;
k = 0:500;
w = (pi/500)*k;
m=n'*k
X11=(exp(-j*pi/500)).^m
X1=x1*X11 % DTFT of x1
X2=x2*X11 % DTFT of x2
X3=x3*X11 % DTFT of x3
X_check=alpha*X1+beta*X2; % linear combination of DTFT
of x1 and DTFT of x2
error=max(abs(X3-X_check)) % check the error

x=rand(1,11) % generate random number
n=0:10
k=0:500
w=(pi/500)*k
m=n'*k
X11=(exp(-j*pi/500)).^m
X=x*X11 %DTFT of x
% generate the shifted version of the signal
y=x;
n_new=n+2; % new values of n
m=n_new'*k
X11=(exp(-j*pi/500)).^m
Y=y*X11; % DTFT of new signal
Y_check=exp(-j*2*w).*X; % multipying by exp(-j2w)
error=max(abs(Y-Y_check)) % difference


6
Example 4: To verify the frequency shift property, we will generate two signals x(n) and y(n) defined by

) 2 / cos( ) ( n n x =

,where 0n100 and

) ( ) (
4 /
n x e n y
n j
=




















Another important property of DTFT is the convolution. One of the major advantages of the DTFT is
that the convolution of two discrete signals becomes multiplication in frequency domain. The following
MatLab code will be helpful to understand the convolution property of DTFT.

Example 5: Find the DTFT of the following two discrete signal given by

x(n)={1 3 5 7 9 11 13 15 17}


h(n)
2
={1 -2 3 -2 1}


The following piece of MatLab code will determine the DTFT of these two signals and verify the
convolution property.






n=0:100
x=cos(pi*n/2) % Generate signal x
k=-100:100
w=(pi/100)*k
m=n'*k
X11=(exp(-j*pi/100)).^m
X=x*X11 % DTFT of x
subplot(211)
plot(w,abs(X)) % plot the magnitude vs w

y=exp(j*pi*n/4).*x % generate y(n)
Y=y*X11 % DTFT of y(n)
subplot(212)
plot(w,abs(Y)) % plot it


7
































Report: Students should submit all the codes and plots related to this experiment.

% Convolution property of DTFT
w=-pi:pi/256:pi
x=[1 3 5 7 9 11 13 15 17]
h=[1 -2 3 -2 1]
X=freqz(x,1,w) % This is an alternative way to find DTFT
of x1(n)
H=freqz(h,1,w) % DTFT of x2(n)
XP=X.*H;

subplot(221)
plot(w/pi,abs(XP))
title('Product of magnitude spectrum')
% find the convolution of x1(n) and x2(n)
subplot(222)
plot(w/pi,angle(XP))
title('Phase spectum')

y=conv(x,h)
Y=freqz(y,1,w)
subplot(223)
plot(w/pi,abs(Y))
title('Magnitude spectrum of convoled sequence')
subplot(224)
plot(w/pi,angle(Y))
title(' Phase of convolved sequence')

You might also like