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

Z- Transform

This document discusses the z-transform method used for analyzing discrete time control systems, including converting linear ordinary difference equations into algebraic equations. It provides MATLAB examples for finding z-transforms and inverse z-transforms for various functions and equations. Additionally, it includes homework assignments related to z-transforms and system responses using MATLAB.

Uploaded by

ali alaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Z- Transform

This document discusses the z-transform method used for analyzing discrete time control systems, including converting linear ordinary difference equations into algebraic equations. It provides MATLAB examples for finding z-transforms and inverse z-transforms for various functions and equations. Additionally, it includes homework assignments related to z-transforms and system responses using MATLAB.

Uploaded by

ali alaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1

MATLAB Applications No. (1)


z - Transform Method

 Objective:
The objectives of this application are to:
1. Converts the linear ordinary difference equations into algebraic
equations in the z- transform.
2. Obtain the discrete time function from the function in the z- domain.
 Introduction:
The z-transform is a mathematical tool commonly used for the analysis
of discrete time control systems. The role of the z- transform in discrete
time systems is similar to that of the Laplace transform in continuous
time systems. In a linear discrete time control system, a linear difference
equation characterizes the dynamics of the system. To determine the
system’s response to a given input, such a difference equation must be
solved. With the z-transform method, the solution to linear difference
equations become algebraic in nature.
The z-transform method is an operational method that is very powerful
when working with discrete time systems, the z-transform is defined by:

𝑋(𝑧) = ʓ (𝑥[𝑘]) = ∑ 𝑥[𝑘]𝑧 −𝑘


𝑘=−∞

Example 1.1: Use MATLAB to find the right side z-transform of the
following elementary functions:

1. 𝑥(𝑡) = 𝑢(𝑡). 𝟐. 𝑥(𝑡) = 𝑡 𝑢(𝑡) . 𝟑. 𝑥(𝑡) = 𝑒 −𝑡 .


4. 𝑥(𝑡) = sin(𝑎𝑡). 5. 𝑥(𝑡) = cos(𝑎𝑡).

Khaled Mustafa Mahmoud Session: Fall 2016/2017


2

Solution:
% 1. To determine the z- transform for unit step function %
syms a k T
x=T^0
X=ztrans(x)
pretty(X)
z
-------
z–1
% 2. To determine the z- transform for unit ramp function %
x=k*T;
X=ztrans(x);
pretty(X)
Tz
----------
(z - 1)2
% 3. To determine the z- transform for exponential function %
x=exp(-k*T);
X=ztrans(x);
pretty(X)
z
--------------
z - exp(-T)
% 4. To determine the z- transform for sine function %
x=sin(a*k*T);
X=ztrans(x);
pretty(X)
z sin(aT)
-------------------------
z2 - 2 z cos(aT) + 1

Khaled Mustafa Mahmoud Session: Fall 2016/2017


3

% 5. To determine the z- transform for cosine function %


x=cos(a*k*T);
X=ztrans(x);
pretty(X)
z (z - cos(aT))
---------------------------
z2 - 2 z cos(aT) + 1

Example 1.2: Use MATLAB to find the right side z-transform of the
following functions:
1. 𝑥(𝑡) = 3𝑢(𝑡) + 2 𝑡𝑢(𝑡)
2. 𝑥(𝑡) = 2 cos(3𝑡) + 𝑒 −2𝑡 sin(2𝑡)
3. 𝑥[𝑘] = 9𝑘(2𝑘−1 ) − 2𝑘 + 3

Solution:
% 1. To determine the z-transform of 𝒙(𝒕) = 𝟑𝒖(𝒕) + 𝟐 𝒕𝒖(𝒕)%
syms k T
x=3+2*k*T;
X=ztrans(x);
pretty(X)
3z 2Tz
-------- + ------------
z-1 (z - 1)2
% 2. To determine the z-transform of 𝟐 𝐜𝐨𝐬(𝟑𝒕) + 𝒆−𝟐𝒕 𝐬𝐢𝐧(𝟐𝒕)%
syms k T
x=2*cos(3*k*T)+exp(-2*k*T)*sin(2*k*T);
X=ztrans(x);
pretty(X)
2 z (z - cos(3 T)) z exp(2 T) sin(2 T)
--------------------------- + ----------------------------------------------------
z2 - 2 cos(3 T) z + 1 exp(4 T) z2 - 2 z exp(2 T) cos(2 T) + 1

Khaled Mustafa Mahmoud Session: Fall 2016/2017


4

% 3. To determine the z-transform of 𝒙(𝒌) = 𝟗𝒌(𝟐𝒌−𝟏 ) − 𝟐𝒌 + 𝟑 %


syms k
x= 9*k*(2^(k-1))-2^k+3;
X=ztrans(x);
pretty(X)
3z z 9z
-------- - -------- + ------------
z-1 z-2 (z -2)2

 Inverse z- Transform:
After transforming equations into the z- domain and solving for output
variables as functions of (z), we sometimes want transform back into the
discrete time domain. This equation is called inversion of z- transforms.
The inverse z- transformation is usually obtained by using partial fraction
expansion - or long division -. The function to be inverted 𝑋(𝑧) is merely
rearranged into a series of simple function:

𝑋(𝑧) = 𝑋1 (𝑧) + 𝑋2 (𝑧) + ⋯ + 𝑋𝑁 (𝑧)

Then each term is inverted (usually by inspection because they are


simple). The total time dependent function in the sum of the individual
time dependent functions:

𝑥[𝑘] = ʓ−1 [𝑋1 (𝑧)] + ʓ−1 [𝑋2 (𝑧)] + ⋯ + ʓ−1 [𝑋𝑁 (𝑧)]

𝑥[𝑘] = 𝑥1 [𝑘] + 𝑥2 [𝑘] + ⋯ + 𝑥𝑁 [𝑘]


Example 1.3: Find the inverse z- transform of the following functions. First,
perform the partial fraction expansion on X(z).
𝑧
𝟏. 𝑋(𝑧) =
(𝑧 − 0.2)(𝑧 − 0.5)
0.1𝑧(𝑧 + 1)
𝟐. 𝑋(𝑧) =
(𝑧 − 1)2 (𝑧 − 0.6)

Khaled Mustafa Mahmoud Session: Fall 2016/2017


5

Solution:
% 1. To perform the partial fraction expansion for: X(z)=z/((z-0.2)(z-0.5))%
a=[1];
b=conv([1 -0.2],[1 -0.5]);
[r,p,k]=residue(a,b)
r=
3.3333
-3.3333
p=
0.5000
0.2000
k=
[]
% To find the inverse z- transform …%
syms k z
X=3.3*z/(z-0.5)-3.3*z/(z-0.2);
x=iztrans(X,k)
x = 3.3*(1/2)^k – 3.3*(1/5)^k
% 2. To perform the partial fraction expansion for: X(z)=0.1z(z+1)/((z-1)2(z-0.6))%
a=[0.1 0.1];
b=conv([1 -1],conv([1 -1],[1 -0.6]));
[r,p,k]=residue(a,b)
r=
-1.0000
0.5000
1.0000
p=
1.0000
1.0000
0.6000
k=
[]

Khaled Mustafa Mahmoud Session: Fall 2016/2017


6

% To find the inverse z- transform …%


syms k z
X=-z/(z-1)+0.5*z/(z-1)^2+z/(z-0.6);
x=iztrans(X,k)
x=
k/2 + (3/5)^k - 1

Example 1.4: Use MATLAB to determine the inverse z – transform for the
following transfer function when the input is the Kronecker delta:
1. In a close form.
2. In a sequence until 𝑥(4).
10𝑧 + 5 10𝑧 −1 + 5𝑧 −2
𝑋(𝑧) = =
(𝑧 − 1)(𝑧 − 0.2) 1 − 1.2𝑧 −1 + 0.2𝑧 −2
Solution:
% % To find the inverse z- transform for: X(z)=(10z+5)/((z-1)(z-0.2))%
% 1. In a close form %
syms k z
X=(10*z+5)/((z-1)*(z-0.2));
x=iztrans(X,k)
x=
25*kroneckerDelta(k, 0) - 43.75*(1/5)^k + 18.75
% 2. In a sequence until x(4) %
a=[0 10 5];
b=[1 -1.2 0.2];
r=[1 zeros(1,4)]
x=filter(a,b,r)
x=
0 10.0000 17.0000 18.4000 18.6800

Khaled Mustafa Mahmoud Session: Fall 2016/2017


7

Example 1.5: Use MATLAB to solve the following difference equations:


1. 𝑥[𝑘 + 2] + 3𝑥[𝑘 + 1] + 2𝑥[𝑘] = 0 , 𝑥[0] = 0, 𝑥[1] = 1.
2. 𝑥[𝑘] − 5𝑥[𝑘 − 1] + 6𝑥[𝑘 − 2] = 𝑢[𝑘] , 𝑥[−1] = 𝑥[−2] = 0

Where 𝑢(𝑘) is the unit step function and is given by:

1 for 𝑘 ≥ 0
𝑢[𝑘] = {
0 for 𝑘 < 0

Solution:
% 1. To determine the z- transform to solve the DE...%
% 𝐱(𝐤 + 𝟐) + 𝟑𝐱(𝐤 + 𝟏) + 𝟐𝐱(𝐤) = 𝟎 , 𝐱(𝟎) = 𝟎, 𝐱(𝟏) = 𝟏%
xk = sym('x(k)');
xk1 = sym('x(k+1)');
xk2 = sym('x(k+2)');
syms k z
eq = xk2 +3*xk1 +2*xk;
Zeq = ztrans(eq, k, z)
syms Xz
Zeq = subs(Zeq,{'ztrans(x(k), k, z)', 'x(0)', 'x(1)'}, {Xz, 0, 1})
eq = collect(Zeq, Xz)
X = solve(eq, Xz)
pretty(X)
z
----------------
z2 + 3 z + 2

x=iztrans(X,k)
x= (-1)^k - (-2)^k

Khaled Mustafa Mahmoud Session: Fall 2016/2017


8

% 2. To determine the z- transform to solve the DE...%


% 𝐱(𝐤) − 𝟓𝐱(𝐤 − 𝟏) + 𝟔𝐱(𝐤 − 𝟐) = 𝐮(𝐤) , 𝐱(−𝟏) = 𝐱(−𝟐) = 𝟎%
xk = sym('x(k)');
xk1 = sym('x(k-1)');
xk2 = sym('x(k-2)');
syms k z
eq = 6*xk2-5*xk1+xk-1;
Zeq = ztrans(eq,k,z)
syms Xz
Zeq = subs(Zeq,{'ztrans(x(k),k,z)', 'x(-1)', 'x(-2)'}, {Xz, 0, 0})
eq = collect(Zeq, Xz)
X = solve(eq, Xz)
pretty(X)
z3
-------------------------
z3 - 6 z2 + 11 z – 6
x=iztrans(X,k)
4.5*(3)^k - 4*(2)^k + 0.5
% In a sequence until x(5) %
a=[1 0 0];
b=[1 -5 6];
u=ones(1,6)
x=filter(a,b,u)
x=
1 6 25 90 301 966

Khaled Mustafa Mahmoud Session: Fall 2016/2017


9

Homework 1.1: Use MATLAB to find the z-transform of the following


functions:
1 𝑘 1 𝑘
1. 𝑥[𝑘] = (− ) 𝑢[𝑘] + 3 ( ) 𝑢[𝑘]
2 5

2 𝑘 1 𝑘
2. 𝑥[𝑘] = (𝑘 (− ) ) 𝑢[𝑘] ∗ ( ) 𝑢[𝑘]
3 4

3. 𝑥(𝑡) = 𝑡 2 𝑒 −3𝑡 + 𝛿(𝑡 − 4)


---------------------------------------------------------------------------------------------
Homework 1.2: Using partial fraction expansion, obtain the inverse z-
transform for the following transfer function:
10
𝟏. 𝑋(𝑧) =
(𝑧 − 1)(𝑧 − 2)
𝑧 −1 (0.5 − 𝑧 −1 )
𝟐. 𝑋(𝑧) =
(1 − 0.5𝑧 −1 )(1 − 0.8𝑧 −1 )2
---------------------------------------------------------------------------------------------
Homework 1.3: Consider a system 𝐻(𝑧) is given by:
𝑌(𝑧) 0.4673𝑧 −1 − 0.3393𝑧 −2
𝐻(𝑧) = =
𝑋(𝑧) 1 − 1.5327𝑧 −1 + 0.6607𝑧 −2
Assume that 𝑥[𝑘], the input to the system 𝐻(𝑧), is the Kronecker delta
input, or:
1 for 𝑘 = 0
𝑥[𝑘] = {
0 for 𝑘 ≠ 0
Do the following using MATLAB:
1. Determine the inverse z – transform of 𝐻(𝑧), let us obtain 𝑦[𝑘] up to
𝑘 = 40.
2. Obtain the output response of the system to the Kronecker delta input.

Khaled Mustafa Mahmoud Session: Fall 2016/2017


10

Homework 1.4: Use MATLAB to determine the inverse z- transform for the
following transfer functions are specified by its Laplace transform:

3
𝟏. 𝐹(𝑠) =
(𝑠 + 1)(𝑠 + 5)2
(𝑠 + 2)
𝟐. 𝐹(𝑠) =
(𝑠 2 + 4)(𝑠 + 8)
---------------------------------------------------------------------------------------------
Homework 1.5: A system is described by the following difference equation:
𝑦[𝑘] − 1.143𝑦[𝑘 − 1] + 0.4128𝑦[𝑘 − 2] = 0.0675𝑥[𝑘]
+ 0.1349𝑥[𝑘 − 1] + 0.675𝑥[𝑘 − 2]
Do the following
1. Write a MATLAB program that will calculate the output 𝑦[𝑘]. Run this
program solving for 𝑦[0], 𝑦[1], … . , 𝑦[30] when the initial conditions
are zero, then obtain the response of the system output to a unit step
input.
2. Repeat part (1) when the input is zero and the initial conditions are
𝑦[−1] = 1 and 𝑦[−2] = 2 using the filter and filtic commands.

Khaled Mustafa Mahmoud Session: Fall 2016/2017

You might also like