0% found this document useful (0 votes)
1 views

LABEX3

Uploaded by

Bảo Nguyễn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

LABEX3

Uploaded by

Bảo Nguyễn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Name: Tran Tuan Kiet

Section:

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:

< Insert program code here. Copy from m-file(s) and paste. >

Answers:
% Program P3_1
% Evaluation of the DTFT
clf;
% Compute the frequency samples of the DTFT
w = -4*pi:8*pi/511:4*pi;
num = [2 1];den = [1 -0.6];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');

1
-The function of the pause command is used to stop MATLAB execution temporarily

Q3.2 The plots generated by running Program P3_1 are shown below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

The DTFT is a __periodic __ function of .

2
Its period is - 2pi

The types of symmetries exhibited by the four plots are as follows:

+ The real part and the magnitude are even symmetrics with a period of 2pi.

+ The imaginary part and the phase are odd symmetrics with a period of 2pi

Q3.3 The required modifications to Program P3_1 to evaluate the given DTFT of Q3.3 are given
below:

< Insert program code here. Copy from m-file(s) and paste. >
% Program P3_1
% Evaluation of the DTFT
clf; close all; clear all;
% Compute the frequency samples of the DTFT
w = 0*pi:8*pi/511:1*pi;
num = [0.7 -0.5 0.3 1];
den = [1 0.3 -0.5 0.7];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));grid
title('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:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

3
4
The DTFT is a ____periodic _____ function of .

Its period is - 2pi

The jump in the phase spectrum is caused by - calculating the phase response using
the arctan function. The form of the phase reponse may be a rational form,
then we can encounter the pole points when ploting this.

The phase spectrum evaluated with the jump removed by the command unwrap is as given
below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
% Evaluation of the DTFT
clf; close all; clear all;
% Compute the frequency samples of the DTFT
w = 0*pi:8*pi/511:1*pi;
num = [0.7 -0.5 0.3 1];
den = [1 0.3 -0.5 0.7];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,unwrap(angle(h)));grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');

Q3.4 The required modifications to Program P3_1 to evaluate the given DTFT of Q3.4 are given
below:

< Insert program code here. Copy from m-file(s) and paste. >

5
6
The plots generated by running the modified Program P3_1 are shown below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

Q3.5 The required modifications to Program P3_1 to plot the phase in degrees are indicated below:

< Insert program code here. Copy from m-file(s) and paste. >

Project 3.2 DTFT Properties

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:

< Insert program code here. Copy from m-file(s) and paste. >

7
The parameter controlling the amount of time-shift is - parameter

Q3.7 The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

8
From these plots we make the following observations:

+ The magnitude spectrum remains the same before.

+ The phase spectrum has a clearly change, the slope is increased

Q3.8 Program P3_2 was run for the following value of the time-shift – D=2

The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

From these plots we make the following observations:

+ The magnitude spectrum still remains the same before.

+ The phase spectrum has a clear change, the slope is increased but less than that of D  10

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 -

The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

9
From these plots we make the following observations: These results are the same as previous
questions.

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:

< Insert program code here. Copy from m-file(s) and paste. >

10
The parameter controlling the amount of frequency-shift is -parameter.

Q3.11 The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

11
From these plots we make the following observations: Both the magnitude and phase
spectra are shifted right by w0 .

Q3.12 Program P3_3 was run for the following value of the frequency-shift -w0  -0,5

The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

From these plots we make the following observations: Both the magnitude and phase
spectra are shifted left by w0 .

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

12
-L = 5 , omega = 0,1

-L=7 , omega = -0,3

The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

From these plots we make the following observations: Both the magnitude and phase
spectra are shifted left/right by w0 .

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:

< Insert program code here. Copy from m-file(s) and paste. >
clf; clear all; close all;
w = -pi:2*pi/255:pi; % frequency vector for evaluating DTFT

13
x1 = [1 3 5 7 9 11 13 15 17]; % first sequence
x2 = [1 -2 3 -2 1]; % second sequence
y = conv(x1,x2); % time domain convolution of x1 and x2
h1 = freqz(x1, 1, w); % DTFT of sequence x1
h2 = freqz(x2, 1, w); % DTFT of sequence x2
% hp is the pointwise product of the two DTFT's
hp = h1.*h2;
% h3 is the DTFT of the time domain convolution;
% it should be the same as hp
h3 = freqz(y,1,w);
% plot the magnitude of the product of the two original
spectra
subplot(2,2,1)
plot(w/pi,abs(hp));grid
title('Product of Magnitude Spectra')
xlabel('\omega /\pi');
ylabel('Amplitude');
% plot the magnitude spectrum of the time domain
convolution
subplot(2,2,2)
plot(w/pi,abs(h3));grid
title('MS of Convolved Sequence')
xlabel('\omega /\pi');
ylabel('Amplitude');
% plot the phase of the product of the two original spectra
subplot(2,2,3)
plot(w/pi,angle(hp));grid
title('Sum of Phase Spectra')
xlabel('\omega /\pi');
ylabel('Phase in radians');
% plot the phase spectrum of the time domain convolution
subplot(2,2,4)
plot(w/pi,angle(h3));grid
title('PS of Convolved Sequence')
xlabel('\omega /\pi');
ylabel('Phase in radians');

Q3.15 The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

14
From these plots we make the following observations: Convolution Property is precisely verified.

Q3.16 Program P3_4 was run for the following two different sets of sequences of varying lengths -

The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

15
From these plots we make the following observations: Convolution Property is precisely
verified.

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:

< Insert program code here. Copy from m-file(s) and paste. >

16
Q3.18 The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

17
From these plots we make the following observations: Modulation Property is precisely
verified.

Q3.19 Program P3_5 was run for the following two different sets of sequences of varying lengths
n=0:15;
x1 = cos(0.1*pi*n);
x2 = sin(0.2*pi*n);

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

From these plots we make the following observations: Modulation Property is precisely
verified.

18
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:

< Insert program code here. Copy from m-file(s) and paste. >

The program implements the time-reversal operation as follows –

Q3.21 The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

From these plots we make the following observations:

The Time-Reversal Property is precisely verified.

19
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:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

20
n = 0:10;

num = cos(0.1*n);

From these plots we make the following observations: The Time-Reversal Property is
precisely verified.

3.2 DISCRETE FOURIER TRANSFORM

Project 3.3 DFT and IDFT Computations

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:

< Insert program code here. Copy from m-file(s) and paste. >
x = [1 2 -1 0 1 1];
L = 6;
clc;close all;
% Question Q3.23
% L=input('Enter the number of points L of the
DFT:');
N=length(x); % input('Enter the length N (N<=L) of
the sequence:');
if L<N
error('L must be equal or greater than N');
% L=input('Enter the number of points L of the
DFT:');
% N=input('Enter the length N (N<=L) of the
sequence:');
elseif L>N
x=[x zeros(1,L-N)];% zero-padding
end

21
y=fft(x,L);
% DTFT
w=linspace(0,2*pi,200);
xf=freqz(x,1,w);
% DTFT
figure(1);
subplot(211);
k=(0:L-1)*2*pi/L;
stem(k,abs(y));
hold on;
plot(w,abs(xf),'r--');
legend('L-DFT','DTFT');
xlabel('Frequency Index');
ylabel('Magnitude Spectrum');
subplot(212);
stem(k,angle(y)*180/pi);
hold on;
plot(w,angle(xf)*180/pi,'r--');
legend('L-DFT','DTFT');
xlabel('Frequency Index');
ylabel('Phase Spectrum');
xn=ifft(y,L);
figure(2);
subplot(211);
stem(x);
xlabel('Time Index');
ylabel('x(n)');
title('The original sequence');
subplot(212);
stem(xn);
xlabel('Time Index');
ylabel('xn(n)');
title('The inverse DFT sequence');

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. >

22
From these plots we make the following observations:
The original sequency with the
sequency implemented N – DFT and I – DFT are the same

23
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. >
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

24
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: The results obtained by computing
G[k] and H[k] with a single N-point DFT or directly with two N-point DFT’s are almost
similar

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. >

25
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. >

Project 3.4 DFT Properties

26
Answers:
Q3.26 The purpose of the command rem in the function circshift is – used to
remainder after division

Q3.27 The function circshift operates as follows:

Q3.28 The purpose of the operator ~= in the function circonv is –

in the function circonv is used to consider the binary relationship NOT EQUAL operator. It
returns 1 if A and B are not equal and vice versal.

Q3.29 The function circonv operates as follows:

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:

< Insert program code here. Copy from m-file(s) and paste. >
% Illustration of Circular Shift of a Sequence
clf; clear all; close all;
% initialize shift amount M
M = 6;
% initialize sequence a to be shifted
a = [0 1 2 3 4 5 6 7 8 9];
b = circshift(a,M); % perform the circular shift
L = length(a)-1;
% plot the original sequence a and the circularly shifted
sequence b
n = 0:L;
subplot(2,1,1);
stem(n,a);axis([0,L,min(a),max(a)]);
title('Original Sequence');
xlabel('time index n');
ylabel('a[n]');
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('time index n');
ylabel('b[n]');

The parameter determining the amount of time-shifting is - M

27
Q3.31 The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

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:

28
< Insert program code here. Copy from m-file(s) and paste. >
% Circular Time-Shifting Property of DFT
clf; clear all; close all;
x = [0 2 4 6 8 10 12 14 16]; % original sequence x
N = length(x)-1; n = 0:N; % time index vector
% set y equal to the circular shift left of x
y = circshift(x,5);
XF = fft(x); % DFT of x
YF = fft(y); % DFT of y
subplot(2,2,1);
% plot the spectral magnitudes of the original and shifted
sequences
stem(n,abs(XF));grid;
title('Magnitude of DFT of Original Sequence');
xlabel('Frequency index k');
ylabel('|X[k]|');
subplot(2,2,2);
stem(n,abs(YF));grid;
title('Magnitude of DFT of Circularly Shifted Sequence');
xlabel('Frequency index k');
ylabel('|Y[k]|');
% plot the spectral phases of the original and shifted
sequences
subplot(2,2,3);
stem(n,angle(XF));grid;
title('Phase of DFT of Original Sequence');
xlabel('Frequency index k');
ylabel('arg(X[k])');
subplot(2,2,4);
stem(n,angle(YF));grid;
title('Phase of DFT of Circularly Shifted Sequence');
xlabel('Frequency index k');
ylabel('arg(Y[k])');

The amount of time-shift is - 5

Q3.33 The plots generated by running the modified program are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

29
From these plots we make the following observations: The Circular Time-Shifting
Property is verified exactly

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:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

30
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. >

31
32
From these plots we make the following observations: The Circular Time-Shifting
Property is verified exactly

Q3.36 A copy of Program P3_9 is 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. >

33
From these plots we make the following observations: The Circular Convolution
Property is verified exactly.

Q3.37 Program P3_9 was run again for the following two different sets of equal-length sequences:

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: The Circular Convolution
Property is verified exactly

Q3.38 A copy of Program P3_10 is given below along with the plots generated by running this
program:

< Insert program code here. Copy from m-file(s) and paste. >
% 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 = Circonv(g1e,g2e);
disp('Linear convolution via circular convolution =
');disp(ylin);
y = conv(g1, g2);
disp('Direct linear convolution = ');disp(y)

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

34
From these plots we make the following observations: Two methods make the same
results.

Q3.39 Program P3_10 was run again for the following two different sets of sequences of unequal
lengths:

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. >

35
From these plots we make the following observations: We can find the linear
convolution of two sequences via the DFT.

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: These methods make the same
final results.

Q3.41 A copy of Program P3_11 is given below:

< Insert program code here. Copy from m-file(s) and paste. >
% Relations between the DFTs of the Periodic Even
% and Odd Parts of a Real Sequence
x = [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]\})');

36
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 - x1[n] is a circular reversal
version of x[n].

Q3.42 The plots generated by running Program P3_11 are given below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

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. >
% Relations between the DFTs of the Periodic Even
% and Odd Parts of a Real Sequence
x = [1 2 4 2 6 32 6 4 2 zeros(1,247)];

37
x1 = [x(1) x(256:-1:2)];
xo = 0.5 *(x - x1);
XF = fft(x);
XOF = fft(xo);
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(XOF)); grid;
xlabel('Time index n');ylabel('Amplitude');
title('Re(DFT\{x_{o}[n]\})');
subplot(2,2,4);
plot(k/128,imag(XOF)); grid;
xlabel('Time index n');ylabel('Amplitude');
title('Im(DFT\{x_{o}[n]\})');

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

38
From these plots we make the following observations: The properties shown in R3.17
was verified exactly.

Q3.44 A copy of Program P3_12 is given below:

< Insert program code here. Copy from m-file(s) and paste. >

The values for a and b we get by running this program are –

Q3.45 The required modifications to Program P3_11 are given below:

< Insert program code here. Copy from m-file(s) and paste. >

3.3 z-TRANSFORM

Project 3.5 Analysis of z-Transforms

Answers:

39
Q3.46 The frequency response of the z-transform obtained using Program P3_1 is plotted below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
clf; clear all; close all;
% Compute the frequency samples of the DTFT
w = 0:8*pi/511:pi;
num = [2 5 9 5 3];
den = [5 45 2 1 1];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');

40
41
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:

< Insert program code here. Copy from m-file(s) and paste. >
function Q3_47
%clc;
%clear all;
close all;
% num. and den. coefficients of Tranfer Function of DF sys.
num=[2 5 9 5 3];
den=[5 45 2 1 1];
% poles and zeros of sys.
[z,p,k]=tf2zp(num,den);
disp('Zeros are:');
disp(num2str(z));
disp('Poles are:');
disp(num2str(p));
% factorized form
disp('TF is factorized as a sum of the following partial
fractions:')
for i=1:length(p)
disp([['(',num2str(z(i)),')'],'/',['(','1-
',['(',num2str(p(i)),')'],'z^-1',')']]);
end
% pole-zero plot
figure(1);

42
zplane(num,den);
% phi=linspace(0,2*pi,200);
% figure(2);
% z=zeros(length(p),200);
% for k=1:length(p)
% z(k,:)=abs(p(k))*exp(j*phi);
% polarplot(phi,z(k,:));
% hold on;
% end
end

Using this program we obtain the following results on the z-transform G(z) of Q3.46:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >
Zeros are:
-1+1.4142i
-1-1.4142i
-0.25+0.66144i
-0.25-0.66144i
Poles are:
-8.9576+0i
-0.27177+0i
0.11466+0.2627i
0.11466-0.2627i
TF is factorized as a sum of the following partial fractions:
(-1+1.4142i)/(1-(-8.9576)z^-1)
(-1-1.4142i)/(1-(-0.27177)z^-1)
(-0.25+0.66144i)/(1-(0.11466+0.2627i)z^-1)
(-0.25-0.66144i)/(1-(0.11466-0.2627i)z^-1)

43
Q3.48 From the pole-zero plot generated in Question Q3.47, the number of regions of convergence
(ROC) of G(z) are -

All possible ROCs of this z-transform are sketched below:

From the pole-zero plot it can be seen that the DTFT – Whether DTFT exists or not is
based not only on the poles but also on the region of convergence.

44
Q3.49 The MATLAB program to compute and display the rational z-transform from its zeros, poles
and gain constant is given below:

< Insert program code here. Copy from m-file(s) and paste. >

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:

Q3.50 The MATLAB program to compute the first L samples of the inverse of a rational z-transform
is given below:

< Insert program code here. Copy from m-file(s) and paste. >

45
The plot of the first 50 samples of the inverse of G(z) of Q3.46 obtained using this program
is sketched below:

< Insert MATLAB figure(s) here. Copy from figure window(s) and paste. >

46
Q3.51 The MATLAB program to determine the partial-fraction expansion of a rational z-transform is
given below:

< Insert program code here. Copy from m-file(s) and paste. >

The partial-fraction expansion of G(z) of Q3.46 obtained using this program is shown below:
r =
0.3109 + 0.0000i
-1.0254 - 0.3547i
-1.0254 + 0.3547i
-0.8601 + 0.0000i
p =
-8.9576 + 0.0000i
0.1147 + 0.2627i
0.1147 - 0.2627i
-0.2718 + 0.0000i
k =
3.0000

From the above partial-fraction expansion we arrive at the inverse z-transform g[n] as
shown below:

Date: Signature: Tran Tuan Kiet

47

You might also like