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

MATLAB For Modern Control Systems

This document provides an overview of using MATLAB to analyze and simulate modern control systems. It discusses representing systems using transfer functions, state-space models, and zero-pole-gain representations. It describes how to obtain system responses, including using the state transition matrix to find the zero input response and lsim to find the zero state response given an input. Configuration blocks like series, parallel and feedback are also covered. MATLAB commands for converting between representations and finding poles, zeros and responses are provided as examples.

Uploaded by

Mikiyas Legesse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views

MATLAB For Modern Control Systems

This document provides an overview of using MATLAB to analyze and simulate modern control systems. It discusses representing systems using transfer functions, state-space models, and zero-pole-gain representations. It describes how to obtain system responses, including using the state transition matrix to find the zero input response and lsim to find the zero state response given an input. Configuration blocks like series, parallel and feedback are also covered. MATLAB commands for converting between representations and finding poles, zeros and responses are provided as examples.

Uploaded by

Mikiyas Legesse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Modern Control Systems MATLAB

Dire Dawa Institute of Technology


School of Electrical and Computer Engineering
ECEg4321: Modern Control Systems
MATLAB Experiments
Chapter – 1
Transfer Function

𝑑 𝑛 𝑦(𝑡) 𝑑 𝑛−1 𝑦(𝑡) 𝑑𝑦(𝑡) 𝑑 𝑚 𝑢(𝑡) 𝑑 𝑚−1 𝑑𝑢(𝑡)


𝑎𝑛 + 𝑎𝑛−1 + ⋯ + 𝑎1 + 𝑎0 𝑦(𝑡) = 𝑏𝑚 + 𝑏𝑚−1 + ⋯ + 𝑏1 + 𝑏0 𝑢(𝑡)
𝑑𝑡 𝑛 𝑑𝑡 𝑛−1 𝑑𝑡 𝑑𝑡 𝑚 𝑑𝑡 𝑚−1 𝑑𝑡

By taking the coefficients


Num = [𝑏𝑚 𝑏𝑚−1 … 𝑏1 𝑏0 ]
Den = [𝑎𝑛 𝑎𝑛−1 … 𝑎1 𝑎0 ]
The transfer function can be determined by using a MATLAB function tf
System = tf(num, den)
Result will be
𝑏𝑚 𝑠𝑚 + 𝑏𝑚−1 𝑠𝑚−1 +⋯+𝑏1 +𝑏0
System = 𝑎𝑛 𝑠𝑛 +𝑎𝑛−1 𝑠𝑛−1 +⋯+𝑎1 +𝑎0

Poles and Zeros of a Transfer Function


tf2zp finds the zeros, poles and gains of a transfer function.
𝑠3 + 11𝑠2 +30𝑠
H(s) = 𝑠4 +9𝑠3 +45𝑠2+87𝑠+50

Num = [1 11 30];
Den = [1 9 45 87 50];
[z, p, k] = tf2zp(Num, Den)
zp2tf finds the num, and den of zero, pole, and gain.
[num, den] = zp2tf(z, p, k)
Then print the system of num and den in ‘s’ polynomials using.

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

printsys(num, den, ‘s’)


To find the roots of the num, and/or den of the transfer function:
roots(num);
roots(den);
The convolution of two polynomials (multiplication of two s-domain functions); num1 and num2
or den1 and den2:
num1 = [1 7 10 9];
num2 = [1 -3 6 2 1];
num = conv(num1, num2);
den1 = [1 7];
den2 = [3 4 5];
den = conv(den1, den2);
Series configuration: If the two blocks are connected as shown below then the blocks are said to
be in series. It would like multiplying two transfer functions. The MATLAB command for the
configuration is “series”.

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

Parallel configuration: If the two blocks are connected as shown below then the blocks are said
to be in parallel. It would like adding two transfer functions.

Feedback configuration: If the blocks are connected as shown below then the blocks are said to
be in feedback. Notice that in the feedback there is no transfer function H(s) defined. When not
specified, H(s) is unity. Such a system is said to be a unity feedback system.

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

When H(s) is non-unity or specified, such a system is said to be a non-unity feedback system as
shown below:

Poles and Zeros of System: To obtain the poles and zeros of the system use the MATLAB
command “pole” and “zero”, respectively. You can also use MATLAB command “pzmap” to
obtain the same as follows.
z = zero(sys) %system zeros
p = pole(sys) %system poles
[p, z] = pzmap(sys) %pole and zero in column vector
pzmap(sys) %pole-zero maps in figure

State-Space Representation
Ẋ = AX + BU
Y = CX + DU
sys = ss(A, B, C, D) %ss is state-space
num = [0 0 1 0];
den = [1 14 56 160];
[A, B, C, D] = tf2ss(num, den) % transfer function (TF) to state space (SS), or
[A,B,C,D] = tf2ss(num,den)
A=
-14 -56 -160
1 0 0
0 1 0
B=
1

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

0
0
C=
0 1 0
D=
0
[num, den] = ss2tf(A, B, C, D) % TF to SS
A = [0 1 0;0 0 1;-5.008 -25.1026 -5.03247];
B = [0;25.04;-121.005];
C = [1 0 0];
D = [0];
[num,den] = ss2tf(A,B,C,D)
num =
0 0 25.0400 5.0080
den =
1.0000 5.0325 25.1026 5.0080
For MIMO system:
[num, den] = ss2tf(A, B, C, D, iu) % where iu is input number.
For first input iu = 1 = U1
For second input iu = 2 = U2
For third input iu = 3 = U3
A = [0 1 0;0 0 1;-9 -8 -7];
B = [7; 8; 9];
C = [2 3 4];
D = 0;
[num, den] = ss2tf(A, B, C, D, 1)
Tss = ss(A, B, C, D) %Form state-space model
Ttf = tf(Tss) %Transform from state-space to transfer function in polynomial form

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

Tzpk =zpk(Tss) %Transform from SS to TF in factored form (Pole/Zero/Gain form)


A = [0 1;-25 -4];
B = [1 1;0 1];
C = [1 0;0 1];
D = [0 0; 0 0];
𝑥̇ 0 1 𝑥1 1 1 𝑢1
| 1| = | | |𝑥 | + | || |
𝑥̇ 2 −25 −4 2 0 1 𝑢2
𝑦1 1 0 𝑥1 0 0 𝑢1
|𝑦 | = | || |+ | || |
2 0 1 𝑥2 0 0 𝑢2
The system involves two inputs and two outputs. Four transfer functions are involved: Y1(s)/U1(s),
Y2(s)/U1(s), Y1(s)/U2(s), and Y2(s)/U2(s). (When considering input U1, we assumed that input U2
is zero (0) and vice versa.
[num, den] = ss2tf(A, B, C, D, 1); % for input one U1
printsys(num, den, 's')
Y1(s)/ U1(s) = num(1)/den =
s+4
--------------
s^2 + 4 s + 25
Y2(s)/ U1(s) = num(2)/den =
-25
--------------
s^2 + 4 s + 25
[num, den] = ss2tf(A, B, C, D, 2); % for input two U2
printsys(num, den, 's')
Y1(s)/ U2(s) = num(1)/den =
1s+5
--------------
s^2 + 4 s + 25
Y2(s)/ U2(s) = num (2)/den =
s - 25

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

--------------
s^2 + 4 s + 25

Chapter – 2
A = [0 -2;1 -3];
dt = 0.2;
phi = expm(A*dt) % finding state transition matrix for a moment (dt = 0.2)
phi =
0.9671 -0.2968
0.1484 0.5219

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

Example
1st method to obtain Responses
clear;
clc;
clf;
t = linspace(0,20);
A = [0 1;-2 -3];
B = [0;1];
C = [1 -1];
D = [0];
sys = ss(A,B,C,D); % for one input (u(t) = u1(t))
u = t; % ramp input u1(t) = t
x0 = [1;2]; %initial condition x(0)
XZIR = initial(sys,x0,t); % Zero Input Response for X(t)
XZSR = lsim(sys,u,t); % Zero State Response for X(t)
XTOTAL = XZIR+XZSR; % Total Response of X(t)
Y = C.*XTOTAL; % Output or System Response Y(t)
plot(t,u,'B',t,XZIR,'G',t,XZSR,'Y',t,XTOTAL,'R',t,Y,'R--
','LineWidth',1); % Plot all the responses
xlabel('Time(s)'); %
ylabel('Responses');
legend('U(t)','XZIR(t)','XZSR(t)','X(t)','Y(t)'); % Giving
legend based on their respective.

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

2nd method to obtain Responses

clear;
clc;
clf;
t = linspace(0,10);
A = [0 1;-2 -3];
B = [0;1];
C = [1 -1];
D = [0];
sys = ss(A,B,C,D); % for one input (u(t) = u1(t))
u = t; % ramp input u1(t) = t
x0 = [1;2]; %initial condition x(0)
[y,T,x] = lsim(sys,u,t,x0); % for calculating output and
state response
subplot(321),plot(t,u); % Plot U(t)
xlabel('Time(s)'),ylabel('U(t)');
subplot(322),plot(T,x(:,1)); % Plot X_1(t) of X(t)
xlabel('Time(s)'),ylabel('X_1(t)');
subplot(323),plot(T,x(:,2)); % Plot X_2(t) of X(t)
xlabel('Time(s)'),ylabel('X_2(t)');
subplot(324),plot(T,x(:,:)); % Plot X(t)
xlabel('Time(s)'),ylabel('X(t)');
subplot(325),plot(T,y); % Plot Y(t)
xlabel('Time(s)'),ylabel('Y(t)');
Y = C.*x; % for checking y(t)
subplot(326),plot(t,Y); % Plot Y(t)
xlabel('Time(s)'),ylabel('Y(t)');

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

Chapter – 3

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

Examples
clc; % clear command window
clear; % Clear workspace
clf; % clear figure
A = [0 1;-2 -3];
B = [0;1];
Qc = ctrb(A,B);
n = det(Qc);
if abs(n) < eps
disp('The system is not completely controllable.')
else
disp('The system is completely controllable.')
end

Output of the code


The system is completely controllable.

clc; % clear command window


clear; % Clear workspace
clf; % clear figure
w = 0.0011; % radial thruster with no tangential thruster
A = [0 1 0 0;3*w^2 0 0 2^w;0 0 0 1;0 -2*w 0 0];

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

B = [0;1;0;0];
Qc = ctrb(A,B);
n = det(Qc);
if abs(n) < eps
disp('Satellite is uncontrollable with radial thruster
only.')
else
disp('Satellite is controllable with radial thruster
only.')
end

Output of the code


Satellite is uncontrollable with radial thruster only.

clc; % clear command window


clear; % Clear workspace
clf; % clear figure
A = [0 1;-2 -3];
C = [1 0];
Qo = obsv(A,C);
n = det(Qo);
if abs(n) < eps
disp('The system is not completely observable.')
else
disp('The system is completely observable.')
end

Output of the code


The system is completely observable.

clc; % clear command window


clear; % Clear workspace
clf; % clear figure
w = 0.0011; % radial thruster with no tangential thruster
A = [0 1 0 0;3*w^2 0 0 2^w;0 0 0 1;0 -2*w 0 0];
C = [0 1 0 0];
Qo = obsv(A,C);
n = det(Qo);
if abs(n) < eps
disp('Satellite is unobservable with radial thruster
only.')
else

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

disp('Satellite is observable with radial thruster


only.')
end

Output of the code


Satellite is unobservable with radial thruster only.

Chapter – 4
State-feedback design (Pole-placement design)

Examples

A = [0 1 0;0 0 1;-1 -5 -6];


B = [0;0;1];
J = [-2+j*4 -2-j*4 -10];
K = acker(A,B,J)
K =
199 55 8

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

A = [0 1;0 0];
B = [0;1];
J = [-1+j -1-j];
K = acker(A,B,J)
K =
2 2
Full-order Observer design

Examples

A = [0 1;20.6 0];
C = [1 0];
J = [-8 -8];
Ke = acker(A',C',J)
Ke =

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

16.0000 84.6000

A = [0 20.6;1 0];
C = [0 1];
J = [-10 -10];
Ke = acker(A',C',J)
Ke =
120.6000 20.0000

Minimum-order Observer design

Examples

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

Abb = [0 1;-11 -6];


Aab = [1 0];
J = [-10 -10];
Ke = acker(Abb',Aab',J)
Ke =
14 5

Prepared by Instructor Sharef H.


Modern Control Systems MATLAB

Abb = [0 1;-24 -10];


Aab = [1 0];
J = [-10 -10];
Ke = acker(Abb',Aab',J)
Ke =
10 -24

Prepared by Instructor Sharef H.

You might also like