Professional Documents
Culture Documents
Section:
Laboratory Exercise 3
DISCRETE-TIME SIGNALS: FREQUENCY-DOMAIN
REPRESENTATIONS
Answers:
Q3.1 The expression of the DTFT being evaluated in Program P3_1 is - (2+e^-jw)/(1-0,6*e^-Jw).
1
Q3.2 The plots generated by running Program P3_1 are shown below :
6
Amplitude
4
0
-4 -3 -2 -1 0 1 2 3 4
/
Imaginary part of H(ej )
4
2
Amplitude
-2
-4
-4 -3 -2 -1 0 1 2 3 4
/
6
Amplitude
0
-4 -3 -2 -1 0 1 2 3 4
/
Phase Spectrum arg[H(e j )]
1
Phase in radians
0.5
-0.5
-1
-4 -3 -2 -1 0 1 2 3 4
/
Its period is - 2
The types of symmetries exhibited by the four plots are as follows : amplitude spectrum and real
spectrum are even functions, imaginary drives and phase spectra are odd functions.
Q3.3 The required modifications to Program P3_1 to evaluate the given DTFT of Q3.3 are given below :
2
w = 0:pi/511:pi;
num = [0.7 -0.5 0.3 1];den = [1 0.3 -0.5 0.7];
The plots generated by running the modified Program P3_1 are shown below :
0.5
Amplitude
-0.5
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/
Imaginary part of H(ej )
1
0.5
Amplitude
-0.5
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/
1.00000000000005
Amplitude
0.99999999999995
0.9999999999999
0 0.2 0.4 0.6 0.8 1
/
Phase Spectrum arg[H(e j )]
4
Phase in radians
-2
-4
0 0.2 0.4 0.6 0.8 1
/
Its period is -
The phase spectrum evaluated with the jump removed by the command unwrap is as given below:
3
Magnitude Spectrum |H(e j )|
1.0000000000001
1.00000000000005
Amplitude
1
0.99999999999995
0.9999999999999
0 0.2 0.4 0.6 0.8 1
/
Phase Spectrum arg[H(e j )]
0
Phase in radians
-2
-4
-6
0 0.2 0.4 0.6 0.8 1
/
Q3.4 The required modifications to Program P3_1 to evaluate the given DTFT of Q3.4 are given below :
num = [1 3 5 7 9 11 13 15 17];den = 1;
h = freqz(num, den,w);
The plots generated by running the modified Program P3_1 are shown below :
50
-50
-250 -200 -150 -100 -50 0 50 100 150 200 250
/180
Imaginary part of H(ej )
100
50
Amplitude
-50
-100
-250 -200 -150 -100 -50 0 50 100 150 200 250
/180
4
Magnitude Spectrum |H(e j )|
80
60
Amplitude
40
20
0
-250 -200 -150 -100 -50 0 50 100 150 200 250
/180
Phase Spectrum arg[H(e j )]
4
Phase in radians
-2
-4
-4 -3 -2 -1 0 1 2 3 4
/180
Its period is -
Q3.5 The required modifications to Program P3_1 to plot the phase in degrees are indicated below :
w = -4*180:8*180/511:4*180;
plot(w/180,angle(h));grid;
Answers:
Q3.6 The modified Program P3_2 created by adding appropriate comment statements, and adding program
statements for labeling the two axes of each plot being generated by the program is given below :
% Program P3_2
% Time-Shifting Properties of DTFT
clf;
w = -pi:2*pi/255:pi; wo = 0.4*pi; D = 10;
num = [1 2 3 4 5 6 7 8 9];
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1));grid
title('Magnitude Spectrum of Original Sequence')
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,2)
plot(w/pi,abs(h2));grid
title('Magnitude Spectrum of Time-Shifted Sequence')
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,3)
plot(w/pi,angle(h1));grid
5
title('Phase Spectrum of Original Sequence')
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,4)
plot(w/pi,angle(h2));grid
title('Phase Spectrum of Time-Shifted Sequence')
xlabel('frequency');
ylabel('Amplitude');
Q3.7 The plots generated by running the modified program are given below:
Amplitude
30 30
20 20
10 10
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Phase Spectrum of Original Sequence
Phase Spectrum of Time-Shifted Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Q3.8 Program P3_2 was run for the following value of the time-shift -5
The plots generated by running the modified program are given below:
6
Magnitude Spectrum of Original Sequence
Magnitude Spectrum of Time-Shifted Sequence
40 40
Amplitude
Amplitude
30 30
20 20
10 10
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Phase Spectrum of Original Sequence
Phase Spectrum of Time-Shifted Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
The plots generated by running the modified program are given below:
Amplitude
10 10
5 5
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Phase Spectrum of Original Sequence
Phase Spectrum of Time-Shifted Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Q3.11 The plots generated by running the modified program are given below:
60 60
Amplitude
Amplitude
40 40
20 20
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Phase Spectrum of Original Sequence
Phase Spectrum of Frequency-Shifted Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Q3.12 Program P3_3 was run for the following value of the frequency-shift - pi
The plots generated by running the modified program are given below:
8
Magnitude Spectrum of Original Sequence
Magnitude Spectrum of Frequency-Shifted Sequence
80 80
60 60
Amplitude
Amplitude
40 40
20 20
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Phase Spectrum of Original Sequence
Phase Spectrum of Frequency-Shifted Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
The plots generated by running the modified program are given below:
30 30
Amplitude
Amplitude
20 20
10 10
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
Phase Spectrum of Original Sequence
Phase Spectrum of Frequency-Shifted Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequence frequence
From these plots we make the following observations : the time domain signal multiplied by the
amount of e exponential is shifted to both the phase spectrum and the amplitude
spectrum over the frequency domain.
Q3.14 The modified Program P3_4 created by adding appropriate comment statements, and adding program
statements for labeling the two axes of each plot being generated by the program is given below :
% Program P3_4
9
% Convolution Property of DTFT
clf;
w = -pi:2*pi/255:pi;
x1 = [1 3 5 7 9 11 13 15 17];
x2 = [1 -2 3 -2 1];
y = conv(x1,x2);
h1 = freqz(x1, 1, w);
h2 = freqz(x2, 1, w);
hp = h1.*h2;
h3 = freqz(y,1,w);
subplot(2,2,1)
plot(w/pi,abs(hp));grid
title('Product of Magnitude Spectra')
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,2)
plot(w/pi,abs(h3));grid
title('Magnitude Spectrum of Convolved Sequence')
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,3)
plot(w/pi,angle(hp));grid
title('Sum of Phase Spectra')
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,4)
plot(w/pi,angle(h3));grid
title('Phase Spectrum of Convolved Sequence')
xlabel('frequency');
ylabel('Amplitude');
Q3.15 The plots generated by running the modified program are given below:
Amplitude
50 50
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequency frequency
Sum of Phase Spectra Phase Spectrum of Convolved Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequency frequency
10
From these plots we make the following observations :
convolution in the time domain is
equivalent to multiplication in the frequency domain.
Q3.16 Program P3_4 was run for the following two different sets of sequences of varying lengths –
x1 = [1 4 3 5 2 7];
x2 = [1 1 3 5 2 9 4 1];
The plots generated by running the modified program are given below:
Amplitude
400 400
200 200
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequency frequency
Sum of Phase Spectra Phase Spectrum of Convolved Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
frequency frequency
11
ylabel('Amplitude');
subplot(3,1,3)
plot(w/pi,abs(h3));grid
title('Magnitude Spectrum of Product Sequence')
xlabel('frequency');
ylabel('Amplitude');
Q3.18 The plots generated by running the modified program are given below:
50
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
frequency
Magnitude Spectrum of Second Sequence
10
Amplitude
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
frequency
Magnitude Spectrum of Product Sequence
Amplitude
50
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
frequency
Q3.19 Program P3_5 was run for the following two different sets of sequences of varying lengths –
x1 = [2 4 1 5 6 8 3 8];
x2 = [5 4 9 3 -2 -7 9 -4];
The plots generated by running the modified program are given below:
12
Magnitude Spectrum of First Sequence
40
Amplitude
20
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
frequency
Magnitude Spectrum of Second Sequence
25
Amplitude
20
15
10
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
frequency
Magnitude Spectrum of Product Sequence
100
Amplitude
50
Q3.21 The plots generated by running the modified program are given below:
13
Magnitude Spectrum of Original Sequence
Magnitude Spectrum of Time-Reversed Sequence
10 10
8 8
6 6
4 4
2 2
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
2 2
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
Q3.22 Program P3_6 was run for the following two different sets of sequences of varying lengths –
num = [-2 4 7 10 5 3 -1];
The plots generated by running the modified program are given below:
14
Magnitude Spectrum of Original Sequence
Magnitude Spectrum of Time-Reversed Sequence
30 30
20 20
10 10
0 0
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
2 2
0 0
-2 -2
-4 -4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
Answers:
Q3.23 The MATLAB program to compute and plot the L-point DFT X[k] of a length-N sequence x[n]
with L N and then to compute and plot the IDFT of X[k] is given below:
Xn=[1 4 6 3 7 -3 2 -7 -5];
Xk=fft(Xn,18);
stem(Xk);
The DFT and the IDFT pairs generated by running the program for sequences of different
lengths N and for different values of the DFT length L are shown below:
15
X(k)
20
10
-10
-20
0 2 4 6 8 10 12 14 16 18
X(n)
10
-5
-10
0 2 4 6 8 10 12 14 16 18
Answers:
Q3.26 The purpose of the command rem in the function circshift is – Remainder after division.
If the amount of time-shift is greater than the sequence length then - The original string will
have trailing zeros added before it is shifted.
Q3.31 The plots generated by running the modified program are given below :
Original Sequence
8
6
amplitude
0
0 1 2 3 4 5 6 7 8 9
time
Sequence Obtained by Circularly Shifting by 6 Samples
8
6
amplitude
0
0 1 2 3 4 5 6 7 8 9
time
Q3.32 The modified Program P3_8 created by adding appropriate comment statements, and adding program
statements for labeling each plot being generated by the program is given below :
% Program P3_8
% Circular Time-Shifting Property of DFT
clf;
x = [0 2 4 6 8 10 12 14 16];
N = length(x)-1; n = 0:N;
y = circshift(x,5);
XF = fft(x);
YF = fft(y);
subplot(2,2,1)
stem(n,abs(XF));grid
title('Magnitude of DFT of Original Sequence');
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,2)
stem(n,abs(YF));grid
title('Magnitude of DFT of Circularly Shifted Sequence');
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,3)
17
stem(n,angle(XF));grid
title('Phase of DFT of Original Sequence');
xlabel('frequency');
ylabel('Amplitude');
subplot(2,2,4)
stem(n,angle(YF));grid
title('Phase of DFT of Circularly Shifted Sequence');
xlabel('frequency');
ylabel('Amplitude');
Q3.33 The plots generated by running the modified program are given below :
60 60
Amplitude
Amplitude
40 40
20 20
0 0
0 2 4 6 8 0 2 4 6 8
frequency frequency
Phase of DFT of Original SequencePhase of DFT of Circularly Shifted Sequence
4 4
2 2
Amplitude
Amplitude
0 0
-2 -2
-4 -4
0 2 4 6 8 0 2 4 6 8
frequency frequency
Q3.34 The plots generated by running the modified program for the following two different amounts of time-
shifts, with the amount of shift indicated, are shown below :
18
function Q3_24
clc;
clear all;
close all;
N=16;% N points
g=rand(1,N);
h=rand(1,N);
x=g+j*h;
Gk=fft(g,N);
Hk=fft(h,N);
Xk=fft(x,N);
Xk_cir=[Xk(1),Xk(end:-1:2)];% Circular folding of Xk
Xk_cir_conj=conj(Xk_cir);% Conjugate of Xk_cir
Gk1=(1/2)*(Xk+Xk_cir_conj);
Hk1=(-j/2)*(Xk-Xk_cir_conj);
dg=Gk-Gk1;
dh=Hk-Hk1;
subplot(611);
stem(abs(Hk));
ylabel('Magnitude');
xlabel('Freq. Index k');
title('N-point DFT of h(n)');
subplot(612);
stem(abs(Hk1));
ylabel('Magnitude');
xlabel('Freq. Index k');
title('N-point DFT of h(n) is computed from Xk');
subplot(613);
stem(abs(dh));
ylabel('Magnitude Error');
xlabel('Freq. Index k');
title('Difference between N-point DFT of h(n) and N-point DFT of h(n) is
computed from Xk');
subplot(614);
stem(abs(Gk));
ylabel('Magnitude');
xlabel('Freq. Index k');
title('N-point DFT of g(n)');
subplot(615);
stem(abs(Gk1));
ylabel('Magnitude');
xlabel('Freq. Index k');
title('N-point DFT of g(n) is computed from Xk');
subplot(616);
stem(abs(dg));
ylabel('Magnitude Error');
xlabel('Freq. Index k');
title('Difference between N-point DFT of g(n) and N-point DFT of g(n) is
computed from Xk');
end
19
N-point DFT of h(n)
10
Magnitude
5
0
0 2 4 6 8 10 12 14 16
Freq. Index k
N-point DFT of h(n) is computed from Xk
10
Magnitude
5
0
0 2 4 6 8 10 12 14 16
Freq. Index k
Magnitude Error
-16
x 10 Difference between N-point DFT of h(n) and N-point DFT of h(n) is computed from Xk
4
2
0
0 2 4 6 8 10 12 14 16
Freq. Index k
N-point DFT of g(n)
10
Magnitude
5
0
0 2 4 6 8 10 12 14 16
Freq. Index k
N-point DFT of g(n) is computed from Xk
10
Magnitude
5
0
0 2 4 6 8 10 12 14 16
Freq. Index k
Magnitude Error
-16
x 10 Difference between N-point DFT of g(n) and N-point DFT of g(n) is computed from Xk
1
0.5
0
0 2 4 6 8 10 12 14 16
Freq. Index k
function Q3_25
clc;
clear all;
close all;
N=16; % N-point DFT
v=rand(1,2*N);
g=v(1:2:length(v)); % g is selected from the even positions of v
h=v(2:2:length(v)); % h is selected from the odd positions of v
Gk=fft(g,N);
Hk=fft(h,N);
Vk=fft(v,2*N);
W=exp(-j*2*pi/(2*N)); % W2N
k=0:2*N-1;
Vk1=[Gk,Gk]+(W.^k).*[Hk Hk];
dv=Vk-Vk1;
subplot(311);
stem(abs(Vk));
ylabel('Mag.');
xlabel('Freq. Index k');
title('2N-point DFT of v');
subplot(312);
stem(abs(Vk1));
ylabel('Mag.');
xlabel('Freq. Index k');
title('Vk is computed alternatively from Gk and Hk');
subplot(313);
stem(abs(dv));
ylabel('Mag. Error');
xlabel('Freq. Index k');
20
title('Comparison of Vk and Vk1');
end
2N-point DFT of v
20
Mag.
10
0
0 5 10 15 20 25 30 35
Freq. Index k
Vk is computed alternatively from Gk and Hk
20
Mag.
10
0
0 5 10 15 20 25 30 35
Freq. Index k
-15
x 10 Comparison of Vk and Vk1
Mag. Error
4
2
0
0 5 10 15 20 25 30 35
Freq. Index k
Q3.38 A copy of Program P3_10 is given below along with the plots generated by running this program :
% Program P3_10
% Linear Convolution via Circular Convolution
g1 = [1 2 3 4 5];g2 = [2 2 0 1 1];
g1e = [g1 zeros(1,length(g2)-1)];
g2e = [g2 zeros(1,length(g1)-1)];
ylin = cconv(g1e,g2e);
subplot(2,1,1);
stem(ylin);
title('Linear convolution via circular convolution');
y = conv(g1, g2);
subplot(2,1,2);
stem(y);
title('Direct linear convolution');
21
Linear convolution via circular convolution
20
15
10
0
0 2 4 6 8 10 12 14 16 18
15
10
0
1 2 3 4 5 6 7 8 9
From these plots we make the following observations : linear convolution can be obtained
via circular convolution.
Q3.39 Program P3_10 was run again for the following two different sets of sequences of unequal
lengths: g1 = [4 1 1 9 -2 5 0 3];g2 = [1 4 -2 5 6 2 0 9]
50
0
0 5 10 15 20 25 30
50
0
0 5 10 15
From these plots we make the following observations : linear convolution can be obtained
via circular convolution.
22
Q3.40 The MATLAB program to develop the linear convolution of two sequences via the DFT of each is given
below:
g1 = [1 2 3 4 5];g2 = [2 2 0 1 1];
f1=fft(g1);f2=fft(g2);
h=conv(ifft(f1),ifft(f2));
The plots generated by running this program for the sequences of Q3.38 are shown below :
20
15
10
0
1 2 3 4 5 6 7 8 9
From these plots we make the following observations : linear convolution can be obtained
via DFT.
The plots generated by running this program for the sequences of Q3.39 are shown below :
100
80
60
40
20
-20
0 5 10 15
23
From these plots we make the following observations : linear convolution can be obtained
via DFT.
The relation between the sequence x1[n] and x[n] is – x1[n] is the signal x[n] to shift around
Q3.42 The plots generated by running Program P3_11 are given below :
Re(DFT{x[n]}) Im(DFT{x[n]})
50
50
Amplitude
Amplitude
0 0
-50 -50
0 0.5 1 1.5 2 0 0.5 1 1.5 2
Amplitude
0 0
-50 -5
0 0.5 1 1.5 2 0 0.5 1 1.5 2
Time index n Time index n
24
The imaginary part of XEF is/is not equal to zero. This result can be explained as follows :
Q3.43 The required modifications to Program P3_11 to verify the relation between the DFT of the periodic
odd part and the imaginary part of XEF are given below along with the plots generated by running this
program :
< Insert program code here. Copy from m-file(s) and paste. >
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
The values for a and b we get by running this program are - 1414528
< Insert program code here. Copy from m-file(s) and paste. >
3.3 z-TRANSFORM
Answers:
Q3.46 The frequency response of the z-transform obtained using Program P3_1 is plotted below :
6
Amplitude
0
-4 -3 -2 -1 0 1 2 3 4
/
Imaginary part of H(ej )
4
2
Amplitude
-2
-4
-4 -3 -2 -1 0 1 2 3 4
/
25
Q3.47 The MATLAB program to compute and display the poles and zeros, to compute and display the
factored form, and to generate the pole-zero plot of a rational z-transform is given below :
num=[2 5 9 5 3];
den=[5 45 2 1 1];
[z p k]=tf2zpk(num,den);
zlpane(z,p);
Using this program we obtain the following results on the z-transform G(z) of Q3.46:
2
Imaginary Part
-1
-2
-3
-4
-9 -8 -7 -6 -5 -4 -3 -2 -1 0 1
Real Part
Q3.48 From the pole-zero plot generated in Question Q3.47, the number of regions of convergence (ROC) of
G(z) are -
The rational form of a z-transform with the given poles, zeros, and gain is found to be
Answers:
Q3.50 The MATLAB program to compute the first L samples of the inverse of a rational z-transform is given
below:
26
num=[2 5 9 5 3];
den=[5 45 2 1 1];
[g,t]=impz(num,den,L);
The plot of the first 50 samples of the inverse of G(z) of Q3.46 obtained using this program is
sketched below:
1045
2
-2
-4
-6
-8
-10
-12
-14
-16
0 5 10 15 20 25 30 35 40 45 50
Q3.51 The MATLAB program to determine the partial-fraction expansion of a rational z-transform is given
below:
Date: Signature:
27