Professional Documents
Culture Documents
Lecture 5&6
Lecture 5&6
Selection of model depends on the particular system and the particular circumstances
1
Example:
m1 x1 k1 x1 k 2 ( x1 x 2 ) b( x 1 x 2 ) u
m2 x2 k 3 x 2 k 2 ( x 2 x1 ) b( x 2 x 1 )
X 1 (s) X 2 ( s)
Obtain the transfer functions:- and
U (s) U ( s) ?
Solution:-
m s
1
2
bs (k1 k 2 ) X 1 ( s ) (bs k 2 ) X 2 ( s ) U ( s ) (1)
m s
2
2
bs (k 2 k ) X
3 2 ( s ) (bs k 2 ) X 1 ( s ) (2)
Solving equation 2 for X 2 ( s ) and substituting it into equation 1 and rearrange it to get:
X 1 (s) m2 s 2 bs k 2 k 3
(3)
U ( s) (m1 s 2 bs k1 k 2 )(m2 s 2 bs k 2 k 3 ) (bs k 2 ) 2
X 2 ( s) bs k 2
U ( s ) (m1 s bs k1 k 2 )(m2 s 2 bs k 2 k 3 ) (bs k 2 ) 2
2
2
Commands covered: tf2zp zp2tf cloop feedback parallel series
Where :
and
Matlab representation:-
In this text, the names of the vectors are generally chosen to be num
and den, but any other name could be used.
3
zeros, poles and gain:
A transfer function may also be defined in terms of its zeros, poles and
gain:
To find the zeros, poles and gain of a transfer function from the vectors num and den
which contain the coefficients of the numerator and denominator polynomials, type
[z,p,k] = tf2zp(num,den)
The zeros are stored in z, the poles are stored in p, and the gain is stored in k.
[num,den] = zp2tf(z,p,k)
4
Overall transfer function of individual systems
The overall transfer function of individual systems in parallel, series or feedback can be
found using MATLAB.
G (s )
R (s ) C (s )
+
-
H (s )
Feedback System
Store the transfer function G in numG and denG, and the transfer function H in
numH and denH. To reduce the general feedback system to a single transfer function,
Type:
For a unity feedback system: let numH = 1 and denH = 1 before applying the
above algorithm. Alternately, use the command
[numT,denT] = cloop(numG,denG,-1);
5
R(s) C(s)
G (s) H (s)
Cascaded system
Type:
G (s)
R(s) C(s)
H (s)
Parallel system
To reduce the parallel system to a single transfer function, T(s) = C(s)/R(s)=G(s) + H(s)
Type:
>>[numT,denT] = parallel(numG,denG,numH,denH);
6
Example
Cascaded system
G2 (s)
Parallel system
Assume :
10 5
G1 ( s) G2 ( s)
G1 (s) s 2s 10
2
s5
Solution
MATLAB program:
num1=[0 0 10];
den1=[1 2 10];
num2=[0 5];
den2=[1 5];
7
Continuous Time System Analysis
Time Simulations
1- residue
[r,p,k] = residue(num,den)
The residues are stored in r, the corresponding poles are stored in p, and the gain is stored
in k.
Once the partial fraction expansion is known, an analytical expression for y(t) can be
computed by hand.
2- step
step(nums,dens)
hold on
step(nums,dens)
holdof
3- impulse
impulse(num,den)
8
4- lsim
t = a:b:c;
where a is the starting time, b is the time step and c is the end time. For
smooth plots, choose b so that there are at least 300 elements in t (increase as
necessary).
t = 0:0.01:5;
x=t
lsim(nums,dens,x,t);
Example:-
num = 2;
den = [1 2];
9
step(num,den);
For the impulse response, simply replace the word step with impulse.
Note:-
y = lsim(num,den,x,t);
plot(t,y)
10
State Space Representation
Where:-
The response of a system to various inputs can be found using the same commands
that are used for transfer function representations: step, impulse, and lsim. The argument
list contains the A, B, C, and D matrices instead of the numerator and denominator
vectors.
Alternately, the system can be combined into one model using the command(ss)
sys = ss(A,B,C,D);
Then, sys can be used as an input argument for the other commands. For example, the
step response is obtained by typing either of the following commands:
[y,t,x] = step(A,B,C,D);
[y,t,x] = step(sys);
The states are stored in x, the outputs in y and the time vector, which
is automatically generated, is stored in t. The rows of x and y contain the
states and outputs for the time points in t. Each column of x represents a
state.
11
plot(t,x(:,2))
impulse(A,B,C,D)
Example:
x 1 1 1 x1 1 1 u1 y1 1 0 x1 0 0 u1
x 6.5 0 x 1 0 u y 0 1 x 0 0 u
2 2 2 2 2 2
0
T:O
o t(1
u
-0.5
B=[1 1; 1 0];
d
litue
2
m
A p
1
t
u(2
0
0 2 4 6 8 10 12
Time (sec)
D=[0 0;0 0];
step-response plots: input = u1 (u2=0 )
0.5
Subplot(2,1,1)
)
0
T:O
o t(1
u
-0.5
Step(A,B,C,D,1)
d
litue
2
m
A p
1
t
u(2
Grid
T:O
o
0
0 2 4 6 8 10 12
Time (sec)
Subplot(2,1,2)
Step(A,B,C,D,2)
Grid
Example:
12
x 1 0 1 x1 0 x
x 1 1 x 1u y 1 0 1 0u
2 2 x2
B1=[0;1];
unit-impulse response
0.6
D1=[0]; 0.4
0.3
Amplitude
impulse(A1,B1,C1,D1)
0.2
hold on 0.1
0
step(A1,B1,C1,D)
-0.1
0 2 4 6 8 10 12
grid
title(‘unit-impulse response’)
Example
C ( s) 1
2
R ( s ) s 0.2 s 1
impulse(num,den) 0.8
0.6
0.4
Grid
Amplitude
0.2
-0.4
-0.6
-0.8
0 10 20 30 40 50 60
Time (sec)
13
Response of arbitrary input:
Define a time vector t and an input matrix u with the same number of
rows as in t and the number of columns equaling the number of inputs. An
optional argument is the initial condition vector x0. The command is then
given as
[y,x] = lsim(A,B,C,D,u,t,x0)
or [y,x] = lsim(sys,u,t,x0)
[num,den] = ss2tf(A,B,C,D);
The numerator coefficients are stored in num and the denominator coefficients are stored
in den.
[Abar,Bbar,Cbar,Dbar]=ss2ss(A,B,C,D,P)
Or [Abar,Bbar,Cbar,Dbar] = ss2ss(sys,P)
performs the similarity transform z=Px resulting in a state space system that is defined as:
14
where
Example:
Y ( s) s
Given the following transfer function:- find the state
U ( s ) ( s 10)( s 4 s 16)
2
space representation?
Y (s) s
Solution: put the transfer function in the following form: 3
U ( s ) s 14s 56 s 160
2
Num=[0 0 1 0]; A B
14 56 160 1 C
Den=[1 14 56 160]; 1 0 0 0 0 1 0
0 1 0 0
[A,B,C,D]=tf2ss(num,den) D
0
The state space representation is:
x 1 14 56 160 x1 1 x1
x 1 0 0 x2 0u y 0 1 0 x2 0u
2
x 3 0 1 0 x3 0 x3
15
Example
Obtain the transfer function of the system defined by the following state space equations:
x 1 0 1 0 x1 0 x1
x 0 0 1 x 2 25 u y 1 0 0 x 2
2
x 3 5 25 5 x3 120 x3
Solution:
B=[0;25;-120]; Den=1 5 25 5
16
Example:
Consider the close loop system
C (s) 1
2
R(s) s s 1
Use Matlab to obtain unit ramp response of this system. For unit ramp input take,
R( s ) 1 .
s2
Solution:
1 1 1 1
C ( s) 2
s s 1 s
2 2
( s s 1) s s
Solution
% the unit ramp response is obtained
% as the unit step response of G(s)/s
Result
num=[0 0 0 1];
unit ramp-response curve
7
den=[1 1 1 0];
6
% specify computing time
5
t=0:0.1:7;
input and output
c=step(num,den,t) 3
1
u=t
0
0 1 2 3 4 5 6 7
plot(t,c,’o’,t,u,’-‘) t sec
17
grid
xlabel(‘t sec’)
Example:
Using the lsim command, obtain the unit-ramp response of the following system:
C (s) 1
2
R(s) s s 1
t=0:0.1:8; 7
r=t; 6
5
y=lsim(num,den,r,t)
input and output
plot(t,r,’-‘,t,y,’o’) 3
0
0 1 2 3 4 5 6 7 8
t sec
18
Example:
x 1 1 0.5 x1 0 x
x 1 0 x 1u y 1 0 1
2 2 x2
Use MATLAB, obtain the response curve y(t) when the input u is given by:
1- u=unit-step input
2- u e t
y=step(A,B,C,D,1,t) 1
up
tut
0.5
u=exp(-t)
0
0 2 4 6 8 10 12
z=lsim(A,B,C,D,u,t) t sec
response to exponential input u=exp(-t)
plot(t,u,'-',t,z,'o',t,y,’x’); 1
0.5
u
op
tut
0
p
linu n
tady
sse
tm
-0.5
ia
0 2 4 6 8 10 12
pn
oet
n
t sec
x
E
19
Response to initial condition:
If the system is given in state space form then use the following command:
initial(A,B,C,D,[intial condition],t)
Example:
Solution:
x 1 0 1 0 x1 x1 (0) 2 x1
x 0 0 1 x 2 x (0) 1 y 1 0 0 x 2
2 2
x 3 10 17 8 x3 x3 (0) 0.5 x3
t=0:0.05:10; Result
B=[0;0;0]; 2
1.5
C=[1 0 0];
1
D=[0]; 0.5
y=initial(A,B,C,D,[2;1;0.5],t); 0
0 1 2 3 4 5 6 7 8 9 10
plot(t,y)
20
res=[t’ y]
n2
It is in the form: G ( s ) 2 is called standard second order system. Given
s 2 n s n2
n and we can use :-
[num,den]=ord2( n , )
Example:
Consider n 5 rad / sec and 0.4 use MATLAB to generate the standard second
order system, and to obtain unit step response?
wn=5; num/den =
damping_ratio=0.4;
[num0,den]=ord2(wn,damping_ratio); 25
num=5^2*num0;
Printsys(num,den,’s’) --------------
% to obtain unit step response
step(num,den) s^2 + 4 s + 25
grid
title(‘Unit-step Response ‘)
21
Tutorial (5&6)
1-
Fig.1
For control system shown in fig-1 use MATLAB to find the overall transfer
function?
2- Find the equations of motion of the dynamic system shown in fig.2,then find
the transfer function X(s)/F(s) between displacement (x) and force (F).
assume M = 1000 kg (a Dodge Neon has a mass of about 1100 kg) b = 40 N*sec/m
µ=0.002 s/m g=9.81 m/s2. Create m-file to represent the transfer function
and to obtain matrices A, B, C, D of the state space form , hence write the
equations in state space form.
Fig-2
22
3- A unity-feedback system is characterized by the open loop transfer
function:
4500
G ( s)
s ( s 361.2)
Plot step response of the system with a cascade controller D(s) with:
(a) D(s)=184.1
(b) D(s)=184.1 + 0.32s
Compare the responses for (a) and (b), and those for (a) and (c). comment
upon the effects of derivative and integral control action.
x 1 4 1 x1 1 x
x 3 1 x 1u y 1 0 1
2 2 x2
23
Case4: a=36 b=9.6
7-
Consider the position control system shown in fig.3 write a MATLAB program
to obtain a unit-step response and a unit-ramp response of the system. Plots
curves x1(t) versus t, x2(t) versus t, x3(t) versus t, and e(t) versus t (where
e(t)=r(t)-x1(t)) for both the unit step response and the unit-ramp response.
C (s) 2s 1
2
R ( s ) s 2s 1
Where ζ=0.2, 0.4, 0.6, 0.8 and 1.0 using MATLAB plot a two-
dimensional diagram of unit-impulse response curves.
24