Lab 5
Lab 5
EE093IU
Submitted by
International University 1
EE093IU
School of CSE
GRADING CHECKLIST
- Header/Footer Yes No
- Spelling Yes No
Total Score
Date:
Signature
International University 2
EE093IU
School of CSE
TEAM CONTRIBUTION
Task Lê Tiến Phát Nguyễn Ngọc Ngân
Collaborated on all coding tasks, participated in problem-solving
Collaboration
discussions, and jointly tested MATLAB implementations
Lab preparation Answer in-class questions
and experiment
Data analysis Jointly analyzed & verified the results for all problems
Write fundamental background & Write experiment procedure &
Report writing
Conclusion Results
International University 3
EE093IU
School of CSE
Table of Contents
List of Figures ........................................................................................….….............................. 4
Discussion of Fundamentals.............................................................................................…….... 5
Experimental Procedure.............................................................................................……........... 6
Results .......................................................................................................................................... 9
Conclusions………...................................................................................................................... 17
List of Figures
Figure 1 – Plotting the Impulse Response 10
Figure 2 – The closed-loop transfer function H(z) 10
Figure 3 – The system stability, zero-pole-gain form, and Partial fraction form 11
Figure 4 – Poles, Zeros, and Impulse Response 12
Figure 5 – Impulse Response of H1(z) and H2(z). 13
Figure 6 – Response to Unit Step and Unit Impulse. 14
Figure 7 – Frequency and Impulse Responses 16
Figure 8 – Step Response 17
International University 4
EE093IU
School of CSE
Discussion of Fundamentals
Discrete-time System
A discrete-time system is any device or algorithm that takes a discrete-time signal x[n] as
input and produces another discrete-time signal y[n] as output. The signals are sequences defined
only at integer time indices n, representing samples of a continuous-time signal or inherently
discrete data. The discrete-time signals involve recognizing sequences, such as unit impulse
(𝛿[n]) and unit step (u[n]), which are fundamental for defining system inputs, such as computing
transfer functions from impulse responses.
Mathematical Representation
Discrete-time systems are often described by linear constant-coefficient difference
equations such as:
y[n] = a1y[n−1] + a2y[n−2] + ⋯ + b0x[n] + b1x[n−1] +…
where y[n] is the output, x[n] the input, and ai, bi are system coefficients. The ability to
perform discrete-time convolution is critical, as it relates to impulse responses, and solving
difference equations is necessary for modeling systems.
Approximations
Discrete-time systems can approximate continuous-time operations, for example:
● Discrete-time differentiator:
𝑥[𝑛] − 𝑥[𝑛 − 1]
𝑦[𝑛] =
𝑇
● Discrete-time integrator:
𝑦[𝑛] = 𝑦[𝑛 − 1] + 𝑇. 𝑥[𝑛]
where T is the sampling period. These approximations become more accurate as T decreases
Transfer Functions
International University 5
EE093IU
School of CSE
The transfer function of a discrete-time system is a fundamental concept that provides a
frequency-domain representation of the system, relating the Z-transform of the output to the Z-
transform of the input. It is a powerful tool for analyzing and designing discrete-time systems,
especially linear time-invariant (LTI) systems.
The discrete-time transfer function H(z) is defined as the ratio of the Z-transform of the
output Y(z) to the Z-transform of the input U(z):
𝑌(𝑧)
𝐻(𝑧) =
𝑈(𝑧)
This function characterizes the system completely in the Z-domain and is typically
expressed as a rational function of z:
𝑏𝑛𝑧𝑛 + 𝑏𝑛−1𝑧𝑛−1+. . . +𝑏1𝑧 + 𝑏0
𝐻(𝑧) =
𝑧𝑚 + 𝑎𝑚−1𝑧𝑚−1+. . . +𝑎1 𝑧 + 𝑎0
where the numerator coefficients 𝑏𝑖 and 𝑎𝑖 denominator coefficients define the system's
zeros and poles, respectively.
Experimental Procedure
Given:
0.5
● 𝐺(𝑧) = 𝑧−0.1
0.2
● 𝐹(𝑧) = 𝑧−0.1
● 𝐾=2
Procedure:
International University 6
EE093IU
School of CSE
1. Determine the structure of the closed control system
𝑌(𝑧) 𝐺(𝑧)𝐾
𝐻(𝑧) = =
𝑈(𝑧) 1 + 𝐺(𝑧)𝐾 𝐹(𝑧)
2. Compute the closed-loop transfer function
𝑧 − 0.4
𝐻(𝑧) =
𝑧2 − 0.5𝑧 + 0.24
3. Find the inverse Z-transform of H(z): using residuez command in MATLAB /
Analyze into partial fractions and look up the reverse Z-transform table, then use
the command impz(num, den) to find the sequence h[n]
8𝑧2 + 10𝑧 − 6
𝐻(𝑧) =
𝑧3 + 2𝑧2 − 𝑧 − 2
Principle:
a. A discrete system is stable if every pole of the transfer function H(z) lies inside
the unit circle, i.e. |p| < 1 for every pole p.
- Determine the poles using the roots of the denominator (the numerator
does not affect stability).
- Calculate the modulus (magnitude) of each pole.
- Compare with 1.
b. Represent the transfer function by “tf2zp”:
(𝑧 − 𝑧1 )(𝑧 − 𝑧2 ) ...
𝐻(𝑧) = 𝑘
(𝑧 − 𝑝1 )(𝑧 − 𝑝2 ) ...
c. Convert the rational fraction H(z) into the sum of simpler fractions by “residue”:
𝐴𝑖
𝐻(𝑧) = ∑ 𝑧 − 𝑝𝑖
International University 7
EE093IU
School of CSE
- The poles are roots of the denominator.
- The unit circle is drawn to evaluate stability.
3. Calculate and plot the impulse response
- Use the impz(num, den, 80) command to calculate the first 80 samples of
the impulse response.
- Use the stem() or stairs() command to plot.
Principle:
a. Create a 2 time unit delay for the system:
- The k-sample delay corresponds to multiplying the system by 𝑧 −𝑘 , so
𝐻2 (𝑧) = 𝑧 −2 . 𝐻(𝑧)
- Plot the impulse response from 0 to 8
b. Find the impulse response of the initial system H(z) by “impz”
c. ℎ2 [𝑛] is to shift ℎ1 [𝑛] 2 units to the right
Process:
1. Determine the numerator and denominator of the system
2. Calculate and plot the response with x[n] as unit impulse: Use the function
impz(num, den, N) to take the first N samples of the impulse response.
3. Calculate and plot the response with x[n] as unit step: Use the function stepz(num,
den, N) to take the first N samples of the step response.
International University 8
EE093IU
School of CSE
Process:
1. Determine the numerator and denominator coefficients from the expression
𝐻(𝑒 𝑗𝜔 )
2. Plot the frequency response (amplitude and phase)
3. Calculate and plot the impulse and step response
- Use impz() to calculate the impulse response
- Use stepz() to calculate the step response
Experimental Results
Problem 1:
clear; clc;
% Define G(z) and F(z)
num_G = [0.5]; den_G = [1, -0.1]; % G(z) = 0.5/(z-0.1)
num_F = [0.2]; den_F = [1, -0.4]; % F(z) = 0.2/(z-0.4)
K = 2;
% Compute K*G(z)
num_KG = K * num_G; den_KG = den_G; % num_KG = [1], den_KG = [1, -0.1]
% Compute K*G(z)*F(z)
num_KGF = conv(num_KG, num_F); % [1] * [0.2] = [0.2]
den_KGF = conv(den_KG, den_F); % [1, -0.1] * [1, -0.4] = [1, -0.5, 0.04]
% Display H(z)
H = tf(num_H, den_H, -1); % -1 for z^-1 convention
disp('Problem 1: Closed-loop transfer function H(z):');
printsys(num_H, den_H, 'z');
Result
International University 9
EE093IU
School of CSE
Figure 1. Result of the program in Problem 1 – Plotting the Impulse Response
Figure 2. Result of the program in Problem 1 – The closed loop transfer function H(z)
Problem 2:
clear; clc;
num = [8, 10, -6]; den = [1, 2, -1, -2];
% a. Check stability
poles = roots(den);
is_stable = all(abs(poles) < 1);
disp('Problem 2a: System stability:');
if is_stable
disp('System is stable (all poles inside unit circle).');
else
disp('System is unstable (some poles outside unit circle).');
International University 10
EE093IU
School of CSE
end
% b. Zero-pole-gain form
[z, p, k] = tf2zp(num, den);
disp('Problem 2b: Zero-pole-gain form:');
disp(['Zeros: ', num2str(z')]);
disp(['Poles: ', num2str(p')]);
disp(['Gain: ', num2str(k)]);
% c. Partial fraction form
[r, p, k] = residue(num, den);
disp('Problem 2c: Partial fraction form:');
syms z
H_partial = 0;
for i=1:length(r)
H_partial = H_partial + r(i)/(z-p(i));
end
disp(vpa(H_partial, 4))
for i = 1:length(r)
disp(['Residue ', num2str(r(i)), ' at pole ', num2str(p(i))]);
end
if ~isempty(k)
disp(['Direct term: ', num2str(k)]);
end
Result
Figure 3. Result of the program in Problem 2 – The system stability, zero - pole - gain form, and Partial fraction form
Problem 3:
clear; clc;
num = [1, 0, 1]; den = [1, -1.39, 1.21];
figure;
Result
Figure 4. Result of the program in Problem 3 – Poles, Zeros, and Impulse Response
Problem 4:
clear; clc;
num1 = [1, 0, 0]; den1 = [1, 0.2, 0.01];
N = 9; % n from 0 to 8
% Impulse response of H_1(z)
[h1, n] = impz(num1, den1, N);
figure;
subplot(2,1,1);
stem(n, h1);
xlabel('n'); ylabel('h_1(n)'); title('Impulse Response of H_1(z)');
Result
Figure 5. Result of the program in Problem 4 – Impulse Response of H1(z) and H2(z).
Problem 5:
clear; clc;
num = [0.01, 0.03, 0.015]; den = [1, -1.6, 0.8];
N = 50; % Sufficient length for visualization
% Impulse response
[h, n] = impz(num, den, N);
figure;
subplot(2,1,1);
stem(n, h);
xlabel('n'); ylabel('y[n]'); title('Response to Unit Impulse');
% Step response
% x_step = ones(1, N);
% y_step = filter(num, den, x_step);
% subplot(2,1,2);
International University 13
EE093IU
School of CSE
% stem(n, y_step);
% xlabel('n'); ylabel('y[n]'); title('Response to Unit Step');
% sgtitle('Problem 5');
Result
Figure 6. Result of the program in Problem 5 – Response to Unit Step and Unit Impulse.
Problem 6:
clear; clc;
num = [0.1, 0.1, 0.18, 0.18, 0.09, 0.09];
den = [1, -1.5, 2.2, -1.5, 0.8, 0.18];
% Frequency response
[H, w] = freqz(num, den, 512);
figure;
subplot(3,1,1);
International University 14
EE093IU
School of CSE
plot(w/pi, 20*log10(abs(H)));
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Magnitude (dB)'); title('Magnitude Response');
subplot(3,1,2);
plot(w/pi, angle(H));
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Phase (radians)'); title('Phase Response');
% Impulse response
[h, n] = impz(num, den);
subplot(3,1,3);
stem(n, h);
xlabel('n'); ylabel('y[n]'); title('Impulse Response');
sgtitle('Problem 6: Frequency and Impulse Responses');
% Step response
% figure;
% x_step = ones(1, length(h));
% y_step = filter(num, den, x_step);
% stem(n, y_step);
% xlabel('n'); ylabel('y[n]'); title('Problem 6: Step Response');
Result
International University 15
EE093IU
School of CSE
Figure 7. Result of the program in Problem 6 – Frequency and Impulse Responses.
International University 16
EE093IU
School of CSE
Figure 8. Result of the program in Problem 6 – Step Response.
Conclusion
Summary of Work
This lab focused on exploring the Z-transform and transfer functions of discrete-time
linear systems. Through a series of theoretical exercises and MATLAB implementations, students
analyzed system behavior using impulse response, step response, pole-zero plots, and frequency
response. The lab provided hands-on experience with MATLAB functions such as tf, zplane, impz,
stepz, and freqz to study system properties in both time and frequency domains.
Key Findings
Theoretical Validation: By deriving closed-loop transfer functions and computing their inverse Z-
transforms, we gained a deeper understanding of how feedback systems behave and how transfer
functions encapsulate their dynamics. Stability analysis was explored by examining the pole
locations in the z-plane, emphasizing that a system is stable only when all poles lie within the unit
International University 17
EE093IU
School of CSE
circle. Impulse and step responses were used to visualize the system's internal behavior,
highlighting how time-domain characteristics evolve in response to specific inputs. Furthermore,
frequency domain analysis using the Z-transform provided valuable insights into how systems
respond across different frequencies, with MATLAB plots closely aligning with theoretical
expectations.
Practical Applications: The concepts and techniques explored in this lab have broad practical
relevance. In digital filter design, understanding Z-transforms and stability is crucial for ensuring
the system behaves as intended. In control systems, accurate modeling using transfer functions
allows engineers to predict and refine system responses. These tools are also widely used in
communications, audio processing, and embedded systems, where efficient and stable digital
signal handling is essential.
Key Points
International University 18
EE093IU
School of CSE
𝑌(𝑧)
𝐻(𝑧) = is central to system analysis. Stability ⇔ All poles lie inside the unit circle ∣z∣<1.
𝑈(𝑧)
Delay in time domain ⇔ Multiply by 𝑧 −𝑘 in Z-domain. Impulse and step responses help understand
time-domain behavior. Frequency response provides magnitude and phase information for system
design and analysis.
THE END
International University 19
EE093IU
School of CSE