0% found this document useful (0 votes)
40 views8 pages

Guia Control en Tiempo Discreto Con MATLAB Tutorial

This document discusses discrete-time systems and some commonly used commands in the MATLAB Control System Toolbox. It provides examples of how to: 1) Discretize a continuous transfer function using the c2d function. 2) Obtain the poles, zeros, step response, and impulse response of a discrete transfer function. 3) Generate a root locus, Bode, and Nyquist plot for analysis of stability and performance.
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)
40 views8 pages

Guia Control en Tiempo Discreto Con MATLAB Tutorial

This document discusses discrete-time systems and some commonly used commands in the MATLAB Control System Toolbox. It provides examples of how to: 1) Discretize a continuous transfer function using the c2d function. 2) Obtain the poles, zeros, step response, and impulse response of a discrete transfer function. 3) Generate a root locus, Bode, and Nyquist plot for analysis of stability and performance.
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/ 8

JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

B.2.2 Discrete-Time Systems

The Control System Toolbox also supports the design and analysis of discrete-time systems.
Some of the most commonly used discrete-time system commands and algorithms are given
in this section.

Discretizing a continuous transfer function. The C2d function can be used to discretize a
continuous system transfer function. The sampling time must be specified. The default method
of discretization is zero-order hold at the inputs, but other methods such as linear interpolation
or bilinear approximation can be selected. For example, consider the continuous-time system
transfer function
1
G(s) = .
s+4
Assuming the sampling period is 0.1 s we can convert the transfer function to discrete time
using the following commands:
>> G = tf(1, [1,4]);
>> Gz = c2d(G, 0.1)
JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

CONTROL SYSTEM TOOLBOX 299

Transfer function:
0.08242
-----------
z - 0.6703

Sampling time: 0.1

Thus, the required discrete time transfer function is


0.08242
G(z) = .
z − 0.6703
In the following example we convert a second-order continuous-time system,
4
G(s) = ,
s2 + 4s + 2
to discrete form, with sampling time 1 s:
>> G = tf(4,[1 4 2]);
>> Gz = c2d(G, 1)

Transfer function:
0.6697 z + 0.1878
---------------------------
z^2 - 0.5896 z + 0.01832

Sampling time: 1

Poles and zeros. The poles and zeros can be obtained as follows:
>> [z,p,k] = zpkdata(Gz,‘v’)

z =
-0.2804

p =
0.5567
0.0329

k =
0.6697

Thus, G(z) has one zero at −0.2804 and two poles at 0.5567 and 0.0329. The d.c. gain is
0.6697.
The positions of the poles and zeros can be plotted on the complex plane using the command
>> pzmap(num,den)

Also, the positions of the poles and zeros and the unit circle in the z-plane can be plotted using
the command
>> zplane(num,den)
JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

300 APPENDIX B MATLAB TUTORIAL

Step Response
2

1.8

1.6

1.4

1.2

0.8

0.6

0.4

0.2

0
0 5 10 15
Time (sec)

Figure B.8 Step response

Step response. The unit step response of G(z) is obtained from


>> num = [0 0.6697 0.1878];
>> den = [1 -0.5896 0.01832];
>> dstep(num,den)

and the response obtained is shown in Figure B.8.

Impulse response. The impulse response of G(z) is obtained by writing


>> num = [0 0.6697 0.1878];
>> den = [1 -0.5896 0.01832];
>> dimpulse(num,den)

and the response is shown in Figure B.9.

Root locus. The root locus diagram with lines of constant damping factor and lines of constant
natural frequency is shown in Figure B.10 and is obtained from
>> zgrid(‘new’);
>> rlocus(num,den)

The gain and the roots at any point on the locus can interactively be found using the command
>> [k,p] = rlocfind(num,den)
JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

Impulse Response
0.7

0.6

0.5

0.4
Amplitude

0.3

0.2

0.1

0
0 5 10 15
Time (sec)

Figure B.9 Impulse response

Root Locus
1
0.5π/T
0.6π/T 0.4π/T
0.8 0.7π/T 0.10.3π/T
0.2
0.6 0.3
0.8π/T 0.4 0.2π/T
0.5
0.4 0.6
0.7
0.9 π/T 0.8 0.1π/T
0.2
Imaginary Axis

0.9

π/T
0
π/T

−0.2
0.9 π/T 0.1π/T

−0.4

0.8π/T 0.2π/T
−0.6

0.7π/T 0.3π/T
−0.8
0.6π/T 0.4π/T
0.5π/T
−1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
Real Axis

Figure B.10 Root locus diagram

301
JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

302 APPENDIX B MATLAB TUTORIAL

Bode Diagram
10

5
Magnitude (dB)

−5

−10

−15
0

− 45
Phase (deg)

−90

−135

−180
10−2 10−1 100 101
Frequency (rad/sec)

Figure B.11 Bode diagram

Bode diagram. The Bode diagram of a discrete time system can be obtained (assuming a
sampling time of 1 s) as
>> dbode(num,den,1);
>> grid

The graph obtained is shown in Figure B.11.

Nyquist diagram. The Nyquist diagram of a discrete time system can be obtained as (assuming
a sampling time of 1 s)
>> dnyquist(num,den,1);

The graph obtained is shown in Figure B.12.

z-Transform. The z-transform of a time function can be found using the MATLAB function
ztrans. Some examples are given below.
The z-transform of f (kT ) = kT is found as
>> syms k T;
>> ztrans(k*T)

ans =
T*z/(z-1)^2
JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

CONTROL SYSTEM TOOLBOX 303

Nyquist Diagram
1.5

0.5
Imaginary Axis

−0.5

−1

−1.5
−1 −0.5 0 0.5 1 1.5 2 2.5
Real Axis

Figure B.12 Nyquist diagram

Notice that k and T are defined as symbols.


Similarly, the z-transform of f (kT ) = sin(akT ) is found as follows:

>> syms a k T;
>> f = sin(a*k*T);
>> ztrans(f)

ans =

z*sin(a*T)/(z^2-2*z*cos(a*T)+1)

or

>> pretty(ans)

z sin(a T)
---------------------
2
z - 2 z cos(a T) + 1

Inverse z-transform. The inverse z-transform of a function can be found using the iztrans
function. Some examples are given below.
JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

304 APPENDIX B MATLAB TUTORIAL

The inverse z-transform of F(z) = T z/(z − 1)2 is obtained as follows:


>> f = T*z/(z-1)^2;
>> iztrans(f)

ans =
T*n
Notice that the default independent variable is n.
Coefficients of partial fraction expansion. MATLAB can be used to determine the coefficients
of the partial fraction expansion. Some examples are given below.
Consider the transfer function
2z 2 − z
G(z) = 2 .
z − 3z + 2
We usually expand the term G(z)/z which gives a form which is usually easy to look up in the
inverse z-transform tables. Thus,
G(z) 2z − 1
= 2 .
z z − 3z + 2
The coefficients of the partial fraction expansion are found as follows:
>> [r,p,k] = residue([2 -1], [1 -3 2])

r =
3
-1

p =
2
1

k =
[]
where r are the residues, p are the poles and k are the direct terms. Thus,
G(z) 3 1
= −
z z−2 z−1
and
3z z
G(z) = −
z−2 z−1
The time function can easily be found using z-transform tables.
Another example is given below where there is one direct term. Consider the transfer function

G(z) 2z 2 + 2z − 1
= 2 .
z z − 3z + 2
The coefficients are found from
>> [r,p,k] = residue([2 2 -1], [1 -3 2])

r =
11
-3
JWBK063-APP-B JWBK063-Ibrahim December 22, 2005 20:37 Char Count= 0

CONTROL SYSTEM TOOLBOX 305

p =
2
1

k =
2
Thus,
G(z) 11 3
= − +2
z z−2 z−1
or
11z 3z
G(z) = − + 2z
z−2 z−1
and the inverse z-transform can be found using z-transform tables.
The following example has a double pole. Consider the transfer function
G(z) z 2 + 4z − 1
= 3 .
z z − 5z 2 + 8z − 4
The coefficients are found from
>> [r,p,k] = residue([0 1 4 -1], [1 -5 8 -4])

r =
-3.0000
11.0000
4.0000

p =
2.0000
2.0000
1.0000

k =
[ ]

There are two poles at z = 2, and this implies that there is a double root. The first residue is
for the first-order term for the double root, and the second residue is for the second-order term
for the double root. Thus,
G(z) −3 11 4
= + +
z z − 2 (z − 2)2 z−1
or
3z 11z 4z
G(z) = − + + .
z − 2 (z − 2) 2 z−1
The MATLAB command residuez can be used to compute the partial fraction expansion when
the transfer function is written in powers of z −1 .

You might also like