lab ex 3
TRANSCRIPT
HOÀNG MINH PHÚC
TRẦN THANH HÙNG
GROUP
LABORATORY EXERCISE 3
DISCRETE-TIME SIGNALS: FREQUENCY-DOMAIN REPRESENTATIONS
3.1 DISCRETE-TIME FOURIER TRANSFORM
Project 3.1 DTFT Computation
A copy of Program P3_1 is given below:clf;% Compute the frequency samples of the DTFTw = -4*pi:8*pi/511:4*pi;num = [2 1];den = [1 -0.6];h = freqz(num, den, w);% Plot the DTFTsubplot(2,2,1)plot(w/pi,real(h));gridtitle('Real part of H(e^{j\omega})')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,2)plot(w/pi,imag(h));gridtitle('Imaginary part of H(e^{j\omega})')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,3)plot(w/pi,abs(h));gridtitle('Magnitude Spectrum |H(e^{j\omega})|')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,4)plot(w/pi,angle(h));gridtitle('Phase Spectrum arg[H(e^{j\omega})]')xlabel('\omega /\pi');ylabel('Phase in radians');
Answers:
Q3.1 The expression of the DTFT being evaluated in Program P3_1 is
The function of the pause command is – is used to wait for user response
Q3.2 The plots generated by running Program P3_1 are shown below:
1
-4 -2 0 2 40
2
4
6
8Real part of H(ej)
/
Am
plitu
de
-4 -2 0 2 4-4
-2
0
2
4Imaginary part of H(ej)
/
Am
plitu
de
-4 -2 0 2 40
2
4
6
8Magnitude Spectrum |H(ej)|
/
Am
plitu
de
-4 -2 0 2 4-2
-1
0
1
2Phase Spectrum arg[H(ej)]
/
Pha
se in
rad
ians
The DTFT is a periodic function of w.
Its period is - 1
The types of symmetries exhibited by the four plots are as follows: x[n] is a real sequence, so the real and the magnitude of its DTFT are even symmetry, the imaginary and the phase of its DTFT are odd symmetry.
Q3.3 The required modifications to Program P3_1 to evaluate the given DTFT of Q3.3 are given below:% Compute the frequency samples of the DTFTw = 0:pi/511:pi;num = [0.7 -0.5 0.3 1];den = [1 0.3 -0.5 0.7];h = freqz(num, den, w);% Plot the DTFTsubplot(2,2,1)plot(w/pi,real(h));gridtitle('Real part of H(e^{j\omega})')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,2)plot(w/pi,imag(h));gridtitle('Imaginary part of H(e^{j\omega})')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,3)plot(w/pi,abs(h));gridtitle('Magnitude Spectrum |H(e^{j\omega})|')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,4)plot(w/pi,angle(h));gridtitle('Phase Spectrum arg[H(e^{j\omega})]')xlabel('\omega /\pi');ylabel('Phase in radians');
The plots generated by running the modified Program P3_1 are shown below:
2
0 0.5 1-1
-0.5
0
0.5
1Real part of H(ej)
/
Am
plitu
de
0 0.5 1-1
-0.5
0
0.5
1Imaginary part of H(ej)
/
Am
plitu
de
0 0.5 11
1
1
1Magnitude Spectrum |H(ej)|
/
Am
plitu
de
0 0.5 1-4
-2
0
2
4Phase Spectrum arg[H(ej)]
/
Pha
se in
rad
ians
The DTFT is a periodic function of w.
Its period is - 1
The jump in the phase spectrum is caused by - The jump in the phase spectrum is caused by an artifact of the arctangent function inside angle that signify zeros in the frequency response.
The phase spectrum evaluated with the jump removed by the command unwrap is as given below:
Q3.4 The required modifications to Program P3_1 to evaluate the given DTFT of Q3.4 are given below:% Compute the frequency samples of the DTFTw = -4*pi:8*pi/511:4*pi;num = [1 3 5 7 9 11 13 15 17];den = 1;h = freqz(num, den, w);% Plot the DTFTsubplot(2,2,1)plot(w/pi,real(h));gridtitle('Real part of H(e^{j\omega})')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,2)plot(w/pi,imag(h));grid
3
title('Imaginary part of H(e^{j\omega})')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,3)plot(w/pi,abs(h));gridtitle('Magnitude Spectrum |H(e^{j\omega})|')xlabel('\omega /\pi');ylabel('Amplitude');subplot(2,2,4)plot(w/pi,angle(h));gridtitle('Phase Spectrum arg[H(e^{j\omega})]')xlabel('\omega /\pi');ylabel('Phase in radians');
The plots generated by running the modified Program P3_1 are shown below:
-4 -2 0 2 4-50
0
50
100Real part of H(ej)
/
Am
plitu
de
-4 -2 0 2 4-100
-50
0
50
100Imaginary part of H(ej)
/
Am
plitu
de
-4 -2 0 2 40
50
100Magnitude Spectrum |H(ej)|
/
Am
plitu
de
-4 -2 0 2 4-4
-2
0
2
4Phase Spectrum arg[H(ej)]
/
Pha
se in
rad
ians
The DTFT is a periodic function of w.
Its period is - 1
The jump in the phase spectrum is caused by an artifact of the arctangent function inside angle that signify zeros in the frequency response.
Q3.5 The required modifications to Program P3_1 to plot the phase in degrees are indicated below:plot(w/pi,angle(h)*180/pi);gridtitle('Phase Spectrum arg[H(e^{j\omega})]')xlabel('\omega /\pi');ylabel('Phase in degrees');
Project 3.2 DTFT Properties
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
4
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));gridtitle('Magnitude Spectrum of Original Sequence')subplot(2,2,2)plot(w/pi,abs(h2));gridtitle('Magnitude Spectrum of Time-Shifted Sequence')subplot(2,2,3)plot(w/pi,angle(h1));gridtitle('Phase Spectrum of Original Sequence')subplot(2,2,4)plot(w/pi,angle(h2));gridtitle('Phase Spectrum of Time-Shifted Sequence')The parameter controlling the amount of time-shift is – 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);
Q3.7 The plots generated by running the modified program are given below:
-1 -0.5 0 0.5 10
20
40
60Magnitude Spectrum of Original Sequence
-1 -0.5 0 0.5 10
20
40
60Magnitude Spectrum of Time-Shifted Sequence
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Original Sequence
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Time-Shifted Sequence
From these plots we make the following observations: magnitude spectrum is not changed and phase spectrum is changed.
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:
5
-1 -0.5 0 0.5 10
20
40
60Magnitude Spectrum of Original Sequence
-1 -0.5 0 0.5 10
20
40
60Magnitude Spectrum of Time-Shifted Sequence
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Original Sequence
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Time-Shifted Sequence
From these plots we make the following observations: when the time-shift is more greater, and phase spectrum is is changed
more.
Q3.9 Program P3_2 was run for the following values of the time-shift and for the following values of length for the sequence - D = 15;
num = [2 7 9 4 5 1 3 8 4];
The plots generated by running the modified program are given below:
-1 -0.5 0 0.5 10
20
40
60Magnitude Spectrum of Original Seq
-1 -0.5 0 0.5 10
20
40
60Magnitude Spectrum of T-Shifted Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Original Sequence
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Time-Shifted Sequence
From these plots we make the following observations: for two different sequences of varying lengths and two different time-shifts, magnitude spectrum is not changed and phase spectrum is changed.
From these plots we make the following observations:
Q3.10 The modified Program P3_3 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:
% Frequency-Shifting Properties of DTFTclf;w = -pi:2*pi/255:pi; wo = 0.4*pi;
6
num1 = [1 3 5 7 9 11 13 15 17];L = length(num1);h1 = freqz(num1, 1, w);n = 0:L-1;num2 = exp(wo*i*n).*num1;h2 = freqz(num2, 1, w);subplot(2,2,1)plot(w/pi,abs(h1));gridxlabel('\omega /\pi');ylabel('Amplitude');title('Magnitude Spectrum of Original Seq')subplot(2,2,2)plot(w/pi,abs(h2));gridxlabel('\omega /\pi');ylabel('Amplitude');title('Magnitude Spectrum of Frequency-Shifted Seq')subplot(2,2,3)plot(w/pi,angle(h1));gridxlabel('\omega /\pi');ylabel('Amplitude');title('Phase Spectrum of Original Seq')subplot(2,2,4)plot(w/pi,angle(h2));gridxlabel('\omega /\pi');ylabel('Amplitude');title('Phase Spectrum of Frequency-Shifted Seq')
The parameter controlling the amount of frequency-shift is - wo
Q3.11 The plots generated by running the modified program are given below:
-1 -0.5 0 0.5 10
50
100
/
Am
plitu
de
Magnitude Spectrum of Original Seq
-1 -0.5 0 0.5 10
50
100
/
Am
plitu
de
Magnitude Spectrum of Frequency-Shifted Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
Am
plitu
de
Phase Spectrum of Original Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
Am
plitu
de
Phase Spectrum of Frequency-Shifted Seq
From these plots we make the following observations: both magnitude spectrum and phase spectrum is shifted. The delay is 0.4*pi.
Q3.12 Program P3_3 was run for the following value of the frequency-shift -
7
The plots generated by running the modified program are given below:
From these plots we make the following observations: when the frequency-shift is reatger, the shift is more than.
Q3.13 Program P3_3 was run for the following values of the frequency-shift and for the following values of length for the sequence - wo=0.8*pi, num1=17:-2:1
The plots generated by running the modified program are given below:
-1 -0.5 0 0.5 10
50
100
/
Am
plitu
de
Magnitude Spectrum of Original Seq
-1 -0.5 0 0.5 10
50
100
/
Am
plitu
de
Magnitude Spectrum of Frequency-Shifted Seq
-1 -0.5 0 0.5 1-2
-1
0
1
2
/
Am
plitu
de
Phase Spectrum of Original Seq
-1 -0.5 0 0.5 1-2
-1
0
1
2
/
Am
plitu
de
Phase Spectrum of Frequency-Shifted Seq
From these plots we make the following observations:with the change above isn’t change Frequency-Shifting Property.
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% Convolution Property of DTFTclf;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);
8
h2 = freqz(x2, 1, w);hp = h1.*h2;h3 = freqz(y,1,w);subplot(2,2,1)plot(w/pi,abs(hp));gridtitle('Product of Magnitude Spectra');xlabel('\omega/\pi');ylabel('amplitude');subplot(2,2,2)plot(w/pi,abs(h3));gridtitle('Magnitude Spectrum of Convolved Sequence');xlabel('\omega/\pi');ylabel('amplitude');subplot(2,2,3)plot(w/pi,angle(hp));gridtitle('Sum of Phase Spectra');xlabel('\omega/\pi');ylabel('amplitude');subplot(2,2,4)plot(w/pi,angle(h3));gridtitle('Phase Spectrum of Convolved Sequence');xlabel('\omega/\pi');ylabel('amplitude');
Q3.15 The plots generated by running the modified program are given below:
-1 -0.5 0 0.5 10
50
100Product of Magnitude Spectra
/
am
plitu
de
-1 -0.5 0 0.5 10
50
100Magnitude Spectrum of Convolved Sequence
/
am
plitu
de
-1 -0.5 0 0.5 1-4
-2
0
2
4Sum of Phase Spectra
/
am
plitu
de
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Convolved Sequence
/
am
plitu
de
From these plots we make the following observations: with two way to compute give the same result.
Q3.16 Program P3_4 was run for the following two different sets of sequences of varying lengths
x1 = [1 3 5 7 9 11 ]; x2 = [1 -2 3 ];
The plots generated by running the modified program are given below:
9
-1 -0.5 0 0.5 10
20
40
60
80Product of Magnitude Spectra
/
ampl
itude
-1 -0.5 0 0.5 10
20
40
60
80Magnitude Spectrum of Convolved Sequence
/
ampl
itude
-1 -0.5 0 0.5 1-4
-2
0
2
4Sum of Phase Spectra
/
ampl
itude
-1 -0.5 0 0.5 1-4
-2
0
2
4Phase Spectrum of Convolved Sequence
/
ampl
itude
From these plots we make the following observations: the above property is not change.
Q3.17 The modified Program P3_5 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_5% Modulation Property of DTFTclf;w = -pi:2*pi/255:pi;x1 = [1 3 5 7 9 11 13 15 17];x2 = [1 -1 1 -1 1 -1 1 -1 1];y = x1.*x2;h1 = freqz(x1, 1, w);h2 = freqz(x2, 1, w);h3 = freqz(y,1,w);subplot(3,1,1)plot(w/pi,abs(h1));gridtitle('Magnitude Spectrum of First Sequence');xlabel('\omega/\pi');ylabel('amplitude');subplot(3,1,2)plot(w/pi,abs(h2));gridtitle('Magnitude Spectrum of Second Sequence');xlabel('\omega/\pi');ylabel('amplitude');subplot(3,1,3)plot(w/pi,abs(h3));gridtitle('Magnitude Spectrum of Product Sequence');xlabel('\omega/\pi');ylabel('amplitude');
Q3.18 The plots generated by running the modified program are given below:
10
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
50
100Magnitude Spectrum of First Sequence
/
ampl
itude
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
5
10Magnitude Spectrum of Second Sequence
/
ampl
itude
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
50
100Magnitude Spectrum of Product Sequence
/
ampl
itude
From these plots we make the following observations:
Q3.19 Program P3_5 was run for the following two different sets of sequences of varying lengths
x1 = [1 3 5 7 9 11 ];
x2 = [1 -2 3 5 7 3 ];
The plots generated by running the modified program are given below:
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
20
40Magnitude Spectrum of First Sequence
/
ampl
itude
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
10
20Magnitude Spectrum of Second Sequence
/
ampl
itude
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
100
200Magnitude Spectrum of Product Sequence
/
ampl
itude
From these plots we make the following observations:
Q3.20 The modified Program P3_6 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:
% Time Reversal Property of DTFTclf;w = -pi:2*pi/255:pi;num = [1 2 3 4];L = length(num)-1;h1 = freqz(num, 1, w);
11
h2 = freqz(fliplr(num), 1, w);h3 = exp(w*L*i).*h2;subplot(2,2,1)plot(w/pi,abs(h1));gridxlabel('\omega/\pi');ylabel('amplitude');title('Magnitude Spectrum of Original Seq')subplot(2,2,2)plot(w/pi,abs(h3));gridxlabel('\omega/\pi');ylabel('amplitude');title('Magnitude Spectrum of Time-Reversed Seq')subplot(2,2,3)plot(w/pi,angle(h1));gridxlabel('\omega/\pi');ylabel('amplitude');title('Phase Spectrum of Original Seq')subplot(2,2,4)plot(w/pi,angle(h3));gridxlabel('\omega/\pi');ylabel('amplitude');title('Phase Spectrum of Time-Reversed Seq')
The program implements the time-reversal operation as follows:h2 = freqz(fliplr(num), 1, w);h3 = exp(w*L*i).*h2;
Q3.21 The plots generated by running the modified program are given below:
-1 -0.5 0 0.5 12
4
6
8
10
/
ampl
itude
Magnitude Spectrum of Original Seq
-1 -0.5 0 0.5 12
4
6
8
10
/
ampl
itude
Magnitude Spectrum of Time-Reversed Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
ampl
itude
Phase Spectrum of Original Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
ampl
itude
Phase Spectrum of Time-Reversed Seq
From these plots we make the following observations both magnitude spectrum and phase spectrum is reverted in frequency domain.
Q3.22 Program P3_6 was run for the following two different sets of sequences of varying lengths:
The plots generated by running the modified program are given below:num = [5 7 3 4 1];
12
-1 -0.5 0 0.5 10
5
10
15
20
/
am
plitu
de
Magnitude Spectrum of Original Seq
-1 -0.5 0 0.5 10
5
10
15
20
/
am
plitu
de
Magnitude Spectrum of Time-Reversed Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
am
plitu
de
Phase Spectrum of Original Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
am
plitu
de
Phase Spectrum of Time-Reversed Seq
num = [11 2 7 8 6 4 8];
-1 -0.5 0 0.5 10
20
40
60
/
am
plitu
de
Magnitude Spectrum of Original Seq
-1 -0.5 0 0.5 10
20
40
60
/
am
plitu
de
Magnitude Spectrum of Time-Reversed Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
am
plitu
de
Phase Spectrum of Original Seq
-1 -0.5 0 0.5 1-4
-2
0
2
4
/
am
plitu
de
Phase Spectrum of Time-Reversed Seq
From these plots we make the following observations: the time-reversal property is not change
3.2 DISCRETE FOURIER TRANSFORM
Project 3.3 DFT and IDFT Computations
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:
% Evaluation of the DFTclf;% Compute the frequency samples of the DFTxn = [1 3 5 7 9 11 13 15 17 2];den = 1;N=length(xn);k=0:N-1;w=2*pi*k/N;Xn = freqz(xn, den, w);%Plot the x[n])subplot(3,1,1)stem(k,xn);gridtitle('x[n]')xlabel('n');ylabel('Amplitude');% Plot the DFTsubplot(3,1,2)
13
stem(w,real(Xn));gridtitle('Real part of X[n]')xlabel('w');ylabel('Amplitude');subplot(3,1,3)stem(w,imag(Xn));gridtitle('Imaginary part of X[n]')xlabel('w');ylabel('Amplitude');
0 1 2 3 4 5 6 7 8 90
10
20x[n]
n
Am
plitu
de
0 1 2 3 4 5 6-100
0
100Real part of X[n]
w
Am
plitu
de
0 1 2 3 4 5 6-50
0
50Imaginary part of X[n]
w
Am
plitu
de
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:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
Q3.24 The MATLAB program to compute the N-point DFT of two length-N real sequences using a single N-point DFT and compare the result by computing directly the two N-point DFTs is given below:
< Insert program code here. Copy from m-file(s) and paste. >
The DFTs generated by running the program for sequences of different lengths N are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
Q3.25 The MATLAB program to compute the 2N-point DFT of a length-2N real sequence using a single N-point DFT and compare the result by computing directly the 2N-point DFT is shown below:
< Insert program code here. Copy from m-file(s) and paste. >
The DFTs generated by running the program for sequences of different lengths 2N are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
Project 3.4 DFT Properties
Answers:
14
Q3.26 The purpose of the command rem in the function circshift is used to get remainder after division between abs(M) and length(x).
Q3.27 The function circshift operates as follows: the first, we compare value between abs(M) and length(x). Then we get remainder after division between abs(M) and length(x), then this value is allocated to M. And the last, as the case maybe whether M is possitive or negative, x[n] is advanced or delayed, respectively.
Q3.28 The purpose of the operator ~= in the function circonv is used to compare the length betwwen x[1] and x[2]. Q3.29 The function circonv operates as follows: the first, we compare the length between x1 and x2, to continue, the
length of x1 must same the length of x2. Then, we get mirror x2. The last we tocombine circularly shifting x2, for loop and sum function to compute as known expression about the circular convolution.
Q3.30 The modified Program P3_7 created by adding appropriate comment statements, and adding program statements for labeling each plot being generated by the program is given below:
% Illustration of Circular Shift of a Sequenceclf;M = 6;a = [0 1 2 3 4 5 6 7 8 9];b = circshift(a,M);L = length(a)-1;n = 0:L;subplot(2,1,1);stem(n,a);axis([0,L,min(a),max(a)]);title('Original Sequence');xlabel('n');ylabel('Amplitude');subplot(2,1,2);stem(n,b);axis([0,L,min(a),max(a)]);title(['Sequence Obtained by Circularly Shifting by ',num2str(M),' Samples']);xlabel('n');ylabel('Amplitude');
The parameter determining the amount of time-shifting is M
If the amount of time-shift is greater than the sequence length then the amount of time-shifting is modulus after M divide the length of a sequence - a.
Q3.31 The plots generated by running the modified program are given below:
0 1 2 3 4 5 6 7 8 90
2
4
6
8
Original Sequence
n
Am
plitu
de
0 1 2 3 4 5 6 7 8 90
2
4
6
8
Sequence Obtained by Circularly Shifting by 6 Samples
n
Am
plitu
de
From these plots we make the following observations: with M>0, we have a new, which is delayed.
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:
15
% Circular Time-Shifting Property of DFTclf;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));gridxlabel('n');ylabel('Amplitude');title('Magnitude of DFT of Original Seq');subplot(2,2,2)stem(n,abs(YF));gridxlabel('n');ylabel('Amplitude');title('Magnitude of DFT of Circularly Shifted Seq');subplot(2,2,3)stem(n,angle(XF));gridxlabel('n');ylabel('Amplitude');title('Phase of DFT of Original Seq');subplot(2,2,4)stem(n,angle(YF));gridxlabel('n');ylabel('Amplitude');title('Phase of DFT of Circularly Shifted Seq');
The amount of time-shift is 5 sample.
Q3.33 The plots generated by running the modified program are given below:
0 2 4 6 80
20
40
60
80
n
Am
plitu
de
Magnitude of DFT of Original Seq
0 2 4 6 80
20
40
60
80
n
Am
plitu
de
Magnitude of DFT of Circularly Shifted Seq
0 2 4 6 8-4
-2
0
2
4
n
Am
plitu
de
Phase of DFT of Original Seq
0 2 4 6 8-4
-2
0
2
4
n
Am
plitu
de
Phase of DFT of Circularly Shifted Seq
From these plots we make the following observations: Circular Time-Shifting Property of DFT only change about Phase.
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:
The amount of time-shift is 10 sample
16
0 2 4 6 80
20
40
60
80
n
Am
plitu
de
Magnitude of DFT of Original Seq
0 2 4 6 80
20
40
60
80
n
Am
plitu
de
Magnitude of DFT of Circularly Shifted Seq
0 2 4 6 8-4
-2
0
2
4
n
Am
plitu
de
Phase of DFT of Original Seq
0 2 4 6 8-4
-2
0
2
4
n
Am
plitu
de
Phase of DFT of Circularly Shifted Seq
The amount of time-shift is 20 sample
0 2 4 6 80
20
40
60
80
n
Am
plitu
de
Magnitude of DFT of Original Seq
0 2 4 6 80
20
40
60
80
n
Am
plitu
de
Magnitude of DFT of Circularly Shifted Seq
0 2 4 6 8-4
-2
0
2
4
n
Am
plitu
de
Phase of DFT of Original Seq
0 2 4 6 8-4
-2
0
2
4
n
Am
plitu
de
Phase of DFT of Circularly Shifted Seq
From these plots we make the following observations: The Circular Time-Shifting Property is certain.
Q3.35 The plots generated by running the modified program for the following two different sequences of different lengths, with the lengths indicated, are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
Q3.36 A copy of Program P3_9 is given below along with the plots generated by running this program:% Program P3_9% Circular Convolution Property of DFT
17
g1 = [1 2 3 4 5 6]; g2 = [1 -2 3 3 -2 1];n=1:length(g1);ycir = circonv(g1,g2);disp('Result of circular convolution = ');disp(ycir)subplot(2,1,1)stem(n,ycir);gridxlabel('n');ylabel('Amplitude');title('Result of circular convolution');G1 = fft(g1); G2 = fft(g2);yc = real(ifft(G1.*G2));disp('Result of IDFT of the DFT products = ');disp(yc)subplot(2,1,2)stem(n,real(yc));xlabel('n');ylabel('Amplitude');title('Result of IDFT of the DFT products');
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 60
10
20
30
n
Am
plit
ude
Result of circular convolution
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 60
10
20
30
n
Am
plit
ude
Result of IDFT of the DFT products
From these plots we make the following observations: circular convolution and IDFT of the DFT products give the same result.
Q3.37 Program P3_9 was run again for the following two different sets of equal-length sequences:
The plots generated are shown below:g1 = [1 2 3 4 5 6 7 8 9 10]; g2 = [1 -2 3 4 7 3 1 3 -2 1];
1 2 3 4 5 6 7 8 9 100
50
100
150
200
n
Am
plitu
de
Result of circular convolution
1 2 3 4 5 6 7 8 9 100
50
100
150
200
n
Am
plitu
de
Result of IDFT of the DFT products
g1 = [1 2 3 4 5 6 7 8 9 10 7 4 6 2 5]; g2 = [1 -2 3 4 5 4 2 7 3 1 3 -2 1 0 5];
18
0 5 10 150
50
100
150
200
250
n
Am
plitu
de
Result of circular convolution
0 5 10 150
100
200
300
n
Am
plitu
de
Result of IDFT of the DFT products
From these plots we make the following observations: circular convolution and IDFT of the DFT products give same result that is certain.
Q3.38 A copy of Program P3_10 is given below along with the plots generated by running this program:% Linear Convolution via Circular Convolutiong1 = [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)];n=0:length(g1e)-1;ylin = circonv(g1e,g2e);disp('Linear convolution via circular convolution = ');disp(ylin);subplot(2,1,1)stem(n,ylin);xlabel('n');ylabel('Amplitude');title('Linear convolution via circular convolution');y = conv(g1, g2);disp('Direct linear convolution = ');disp(y)subplot(2,1,2)stem(n,y);xlabel('n');ylabel('Amplitude');title('Direct linear convolution');
0 1 2 3 4 5 6 7 80
5
10
15
20
25
n
Am
plit
ude
Linear convolution via circular convolution
0 1 2 3 4 5 6 7 80
10
20
30
n
Am
plit
ude
Direct linear convolution
From these plots we make the following observations: Linear convolution via circular convolution and Direct linear convolution give the same result.
19
Q3.39 Program P3_10 was run again for the following two different sets of sequences of unequal lengths:
The plots generated are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
Q3.40 The MATLAB program to develop the linear convolution of two sequences via the DFT of each is given below:
< Insert program code here. Copy from m-file(s) and paste. >
The plots generated by running this program for the sequences of Q3.38 are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
The plots generated by running this program for the sequences of Q3.39 are shown below:
< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
From these plots we make the following observations:
Q3.41 A copy of Program P3_11 is given below:
% Relations between the DFTs of the Periodic Even% and Odd Parts of a Real Sequencex = [1 2 4 2 6 32 6 4 2 zeros(1,247)];x1 = [x(1) x(256:-1:2)];xe = 0.5 *(x + x1);XF = fft(x);XEF = fft(xe);clf;k = 0:255;subplot(2,2,1);plot(k/128,real(XF)); grid;ylabel('Amplitude');title('Re(DFT\{x[n]\})');subplot(2,2,2);plot(k/128,imag(XF)); grid;ylabel('Amplitude');title('Im(DFT\{x[n]\})');subplot(2,2,3);plot(k/128,real(XEF)); grid;xlabel('Time index n');ylabel('Amplitude');title('Re(DFT\{x_{e}[n]\})');subplot(2,2,4);plot(k/128,imag(XEF)); grid;xlabel('Time index n');ylabel('Amplitude');title('Im(DFT\{x_{e}[n]\})');
The relation between the sequence x1[n] and x[n] is mirror image each orther.
Q3.42 The plots generated by running Program P3_11 are given below:
20
0 0.5 1 1.5 2-50
0
50
100
Am
plitu
de
Re(DFT{x[n]})
0 0.5 1 1.5 2-100
-50
0
50
100
Am
plitu
de
Im(DFT{x[n]})
0 0.5 1 1.5 2-50
0
50
100
Time index n
Am
plitu
de
Re(DFT{xe[n]})
0 0.5 1 1.5 2
-0.5
0
0.5
x 10-14
Time index n
Am
plitu
de
Im(DFT{xe[n]})
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. >
From these plots we make the following observations:
Q3.44 A copy of Program P3_12 is given below:
% Parseval's Relationx = [(1:128) (128:-1:1)];XF = fft(x);a = sum(x.*x)b = round(sum(abs(XF).^2)/256)disp('a=');disp(a);disp('b=');disp(b);
The values for a and b we get by running this program are: a=1414528 ; b=1414528
Q3.45 The required modifications to Program P3_11 are given below:
% Parseval's Relationx = [(1:128) (128:-1:1)];XF = fft(x);a = sum(x.*x)XFconj=conj(XF);b=round(sum(XF.*XFconj)/256);disp('a=');disp(a);disp('b=');disp(b);
3.3 z-TRANSFORM
Project 3.5 Analysis of z-Transforms
Answers:
Q3.46 The frequency response of the z-transform obtained using Program P3_1 is plotted below:
21
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];zplane(num, den);grid;title('The pole-zero plot of a rational z-transform G(z)');[z, p, k] = tf2zp(num,den);sos=(zp2sos(z,p,k));disp(sos);
Using this program we obtain the following results on the z-transform G(z) of Q3.46:
22
Sos= [0.4000 0.8000 1.2000 1.0000 9.2293 2.4344;
1.0000 0.5000 0.5000 1.0000 -0.2293 0.0822]
Q3.48 From the pole-zero plot generated in Question Q3.47, the number of regions of convergence (ROC) of G(z) are |z|>max|pi|=8.9576
All possible ROCs of this z-transform are sketched below:
From the pole-zero plot it can be seen that the DTFT doesn’t exist because the ROC of G(z) doesn’t include the unit circle.
Q3.49 The MATLAB program to compute and display the rational z-transform from its zeros, poles and gain constant is given below:
r = [0.3; 2.5; -0.2+0.4i; -0.2-0.4i];p = [0.5; -0.75; 0.6+0.7i; 0.6-0.7i];k =3.9;[num,den] = zp2tf(r,p,k);disp('num='),disp(num);disp('den='),disp(den);
The rational form of a z-transform with the given poles, zeros, and gain is found to be:
Project 3.6 Inverse z-Transform
Answers:
L=input('Input the samples of the inversetransform: L= ');num = [2 5 9 5 3];den = [5 45 2 1 1];stem(impz(num,den,L));
23
title(['The inverse transform with Samples with ',num2str(L),' Samples'])xlabel('Time ')
Q3.50 The MATLAB program to compute the first L samples of the inverse of a rational z-transform is given below:
The plot of the first 50 samples of the inverse of G(z) of Q3.46 obtained using this program is sketched below:
Q3.51 The MATLAB program to determine the partial-fraction expansion of a rational z-transform is given below:num = [2 5 9 5 3]; den = [5 45 2 1 1];
[r,p,k]=residuez(num,den);disp('r='),disp(r);disp('p='),disp(p);disp('k='),disp(k);
The partial-fraction expansion of G(z) of Q3.46 obtained using this program is shown below:
r=
0.3109
-1.0254 - 0.3547i
-1.0254 + 0.3547i
-0.8601
p=
-8.9576
0.1147 + 0.2627i
0.1147 - 0.2627i
-0.2718
k=
3.0000
From the above partial-fraction expansion we arrive at the inverse z-transform g[n] as shown below:
24
25