Professional Documents
Culture Documents
13-ES 205
Signal Processing-Lab-6
DT Sequences and Systems: Frequency-Domain
Representation (DTFT)
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Lab Report
Introduction: A linear and time-invariant system can be represented using its response
to the unit sample sequence. This response, called the unit impulse response h[n] ,
allows us to compute the system response to any arbitrary input x[ n] using the linear
convolution. This convolution representation is based on the fact that any signal can be
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Objectives:
To compute the discrete time Fourier transform ( DTFT) for DT sequences and
LTI systems.
To determine and display the Magnitude and phase spectrum of given
sequences and LTI systems.
To find out real part and imaginary part of the spectrum.
1
2
x[n] X [e j ] e jn d .
X [e j ] X re [e j ] j X im [e j ]
X [e j ] | X [e j ] | e j []
j
where [] arg X [e ]
The quantity | X [e j ] | is called the magnitude function and the quantity [] is
called the phase function, with both functions again being real functions of . In many
applications, the Fourier transform is called the Fourier spectrum and, likewise,
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
The response of an LTI system for any arbitrary sequences in time domain can be
represented by using a convolution sum y[n] x[n] h[n] , where x[n] is input
system and y[n] is the response of the system. According to the convolution theorem,
the convolution in time domain is multiplication in frequency domain,
System
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Examples:
Ex1: Determine the DTFT of x[ n] (0.5)n u[ n] analytically. Develop Matlab script for the
same and plot its magnitude, angle, real and imaginary parts. Also show that DTFT is
periodic sequence.
Ans: Analytical Solution
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
X [e j ]
n
x[n] e jn
n 0
(0.5)n e jn
1
(0.5e j )n
n 0 j
1 0.5e
V6_1: Frequency spectrum (DTFT) using analytical solution
k = -300:300;
w = (pi/100)*k;
magX = abs(X);
angX = angle(X);
realX = real(X);
imagX = imag(X);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
R a d ia n s ---->
0.5
1.5
0
1
-0.5
0.5 -1
-4 -2 0 2 4 -4 -2 0 2 4
frequency in pi units----> frequency in pi units---->
Real Part---> Imaginary Part
2 1
I m a g in a ry ---->
0.5
1.5
R eal
0
1
-0.5
0.5 -1
-4 -2 0 2 4 -4 -2 0 2 4
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Mat lab Script for DTFT of a given sequence using freqz.m function
V6_2.m:
k = -300:300;
w = (pi/100)*k;
num = [1];
den = [ 1 -0.5];
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
magX = abs(X);
angX = angle(X);
realX = real(X);
imagX = imag(X);
0.5
Magnitude---->
Radians---->
1.5
0
1
-0.5
0.5 -1
-4 -2 0 2 4 -4 -2 0 2 4
frequency in pi units----> frequency in pi units---->
Real Part---> Imaginary Part
2 1
0.5
nary---->
1.5
eal
0
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
From the magnitude and phase spectrums, it is concluded that the spectrum of given
aperiodic sequence is a periodic sequence with period 2 .
n
h[ n] 0.9 u[n] . Plot the magnitude and the phase responses.
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
1
H [e j ]
1 0.9e j
1 1
| H [e j ] | , and
(1 0.9 cos ) 2 +(0.9 cos ) 2 1.811.8 cos
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
0.9 sin
H [e j ] arctan
1 0.9 cos
V6_3.m:
k = -300:300;
w = (pi/100)*k;
H = exp(j*w) ./ (exp(j*w) - 0.9*ones(size(w)));
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
magH = abs(H);
angH = angle(H);
Magnitude Spectrum
15
M a g n itu d e ---->
10
0
-3 -2 -1 0 1 2 3
frequency in pi units---->
Phase Spectrum
2
R a d ia n s ---->
-1
-2
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Ex3: An LTI system is specified by the difference equation y[n] 0.8y[n 1] x[n]
(a) Determine H [e j ] .
(b) Calculate and plot the steady-state response yss [n] to x[ n] cos[0.05 n]u[n]
Ans: Analytical Solution
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
1
(a) H [e j ]
1 0.8e j
(b) In the steady state the input is x[ n] cos[0.05 n]u[n] with frequency
1
H [e j 0.05 ] 4.0928e j 0.5377
1 0.8e j 0.05
Therefore
yss [n] 4.0928 cos(0.05 n 0.5377) 4.0928 cos [0.05 ( n 3.42)]
This means that at the output the sinusoid is scaled by 4.0928 and shifted by 3.42.
V6_4.m:
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
k = -300:300;
w = (pi/100)*k;
magH = abs(H);
angH = angle(H);
figure();
subplot(2,1,1); plot(w/pi,magH,'r','LineWidth',1.5); grid
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
b = 1; a = [1,-0.8];
n = 0:100;
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
x = cos(0.05*pi*n);
y = filter(b,a,x);
figure();
subplot(2,1,1); stem(n,x,'r','LineWidth',1.5);
xlabel('n'); ylabel('x[n]'); title('Input sequence');
subplot(2,1,2); stem(n,y,'b','LineWidth',1.5);
xlabel('n'); ylabel('y[n]'); title('Output sequence');
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Magnitude Spectrum
15
M a g n it u d e ---->
10
0
-3 -2 -1 0 1 2 3
frequency in pi units---->
Phase Spectrum
2
R a d ia n s ---->
-1
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Input sequence
1
0.5
x [n]
-0.5
-1
0 10 20 30 40 50 60 70 80 90 100
n
Output sequence
5
y [n ]
0
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Laboratory Exercise-6
Exercise1: Determine the DTFT analytically for following sequences.
n
(a) x[ n] {2 1 0 1 2} (b) x[ n] 1
2
u[n 2] (c) x[ n] (0.8) | n |
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
(d) h[ n] [n] 6 [ n 1] 3 [n 2]
a)
clear all; close all; clc;
k = -300:300;
w = (pi/100)*k;
X = -2*exp(2*j*w)-exp(j*w)+exp(-j*w)+2*exp(-2*j*w);
magX = abs(X);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
angX = angle(X);
realX = real(X);
imagX = imag(X)
R a d ia n s ---->
1
4
0
2
-1
0 -2
-4 -2 0 2 4 -4 -2 0 2 4
frequency in pi units----> frequency in pi units---->
-16
x 10 Real Part---> Imaginary Part
4 10
Im a g in a ry ---->
2 5
Real
0 0
-2 -5
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
b)
clear all; close all; clc;
k = -300:300;
w = (pi/100)*k;
X =exp(j*w)./(exp(j*w)-0.5)+0.5*exp(2*j*w)+0.5*exp(j*w);
magX = abs(X);
angX = angle(X);
realX = real(X);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
imagX = imag(X)
title('Real Part--->');
0.5
Radians---->
2
0
1
-0.5
0 -1
-4 -2 0 2 4 -4 -2 0 2 4
frequency in pi units----> frequency in pi units---->
Real Part---> Imaginary Part
3 0.4
ginary---->
0.2
2
Real
0
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
c)
clear all; close all; clc;
k = -300:300;
w = (pi/100)*k;
X =-1+1./(1-(0.8*exp(j*w)))+1./(1-(0.8*exp(-j*w)));
magX = abs(X);
angX = angle(X);
realX = real(X);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
imagX = imag(X)
title('Real Part--->');
0.5
Radians---->
5 0
-0.5
0 -1
-4 -2 0 2 4 -4 -2 0 2 4
frequency in pi units----> frequency in pi units---->
Real Part---> Imaginary Part
10 1
inary---->
0.5
Real
5 0
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
d)
clear all; close all; clc;
k = -300:300;
w = (pi/100)*k;
X =1+6*exp(-j*w)+3*exp(-2*j*w)
magX = abs(X);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
angX = angle(X);
realX = real(X);
imagX = imag(X)
Radians ---->
8 2
6 0
4 -2
2 -4
-4 -2 0 2 4 -4 -2 0 2 4
frequency in pi units----> frequency in pi units---->
Real Part---> Imaginary Part
10 10
Im aginary ---->
5
5
Real
0
0
-5
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Exercise2: The following finite duration sequences are called windows and are very
useful in DSP. Develop Matlab codes for frequency response and plot them. Use N=25.
1, N21 n N21
Rectangular Window: RN [n]
0, elsewhere
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
|n|
1 , for N21 n N21
Triangular Window: TN [n] ( N 1) / 2
0, elsewhere
n
Hamming Window: 0.54 0.46 cos , for N21 n N21
H N [n] ( N 1) / 2
0, elsewhere
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
t=-12:1:12;
w=rectwin(t);subplot(1,1,1);
stem(t,y1);ylabel('Amplitude --.');
xlabel('(b) n --.');
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
0.9
0.8
0.7
0.6
Amplitude --.
0.5
0.4
0.3
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
t=-12:1:12;
y1=1-(abs(t)/12);subplot(2,2,1);
stem(t,y1);ylabel('Amplitude --.');
xlabel('n');
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
0.9
0.8
0.7
0.6
mplitude --.
0.5
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
n=-12:1:12;
y1=0.54+0.46*cos(pi*n)/12;
stem(n,y1);ylabel('Amplitude --.');
xlabel('n');
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
0.7
0.6
0.5
Amplitude --.
0.4
0.3
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
1 4 1 1
(a) y[ n] x[n m]
5 m 0
(b) y[n]
2
y[n 1] x[n] x[n 1]
4
a) k= -300:300;
w = (pi/100)*k;
H =0.2+0.2*exp(-j*w)+0.2*exp(-2*j*w)+0.2*exp(-3*j*w)+0.2*exp(-4*j*w);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
magH = abs(H);
angH = angle(H);
Magnitude Spectrum
1
Magnitude---->
0.5
0
-3 -2 -1 0 1 2 3
frequency in pi units---->
Phase Spectrum
4
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
k = -300:300;
w = (pi/100)*k;
H =4-exp(-j*w)./4-(2*exp(-j*w));
magH = abs(H);
angH = angle(H);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Magnitude Spectrum
8
6
Magnitude---->
0
-3 -2 -1 0 1 2 3
frequency in pi units---->
Phase Spectrum
1
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
1 e j 2
j ]
H [e ,
1 12 e j
2
n
Determine the output y[n] for all n if the input for all n is x[n] sin 4 analytically.
Develop Matlab scripts for the magnitude and phase responses and plot
Matlab code:
% ------------------------------------------------------------
magH = abs(H);
angH = angle(H);
% ------------------------------------------------------------
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
b = [1,-1]; a = [1,0.5];
n = 0:100;
x = sin(0.25*pi*n);
y = filter(b,a,x);
figure();
subplot(2,1,1); stem(n,x,'r','LineWidth',1.5);
xlabel('n'); ylabel('x[n]'); title('Input sequence');
subplot(2,1,2); stem(n,y,'b','LineWidth',1.5);
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Magnitude Spectrum
4
3
Magnitude---->
0
-3 -2 -1 0 1 2 3
frequency in pi units---->
Phase Spectrum
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205
Input sequence
1
0.5
x[n]
-0.5
-1
0 10 20 30 40 50 60 70 80 90 100
n
Output sequence
1
Signal Processing Lab, Dept. of ECE, KL University, A.P., India.
13-ES 205