Professional Documents
Culture Documents
1 Funded
Book Description
Title: Linear Control Systems
Author: B. S. Manke
Publisher: Khanna Publishers
Edition: 9
Year: 2009
ISBN: 81-7409-107-6
Scilab numbering policy used in this document and the relation to the
above book.
Exa Example (Solved example)
Eqn Equation (Particular equation of the above book)
AP Appendix to Example(Scilab Code that is an Appednix to a particular
Example of the above book)
For example, Exa 3.51 means solved example 3.51 of this book. Sec 2.3 means
a scilab code whose theory is explained in Section 2.3 of the book.
Contents
List of Scilab Codes
1 INTRODUCTION
13
2 TRANSFER FUNCTIONS
21
3 BLOCK DIAGRAMS
24
38
47
56
79
137
163
202
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
13
14
14
15
15
16
16
17
17
18
18
19
20
21
23
24
25
26
26
27
28
29
30
31
32
33
33
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
35
36
36
38
39
39
40
40
41
42
43
44
44
45
46
47
48
48
49
50
50
51
52
53
53
54
56
57
58
58
59
60
61
62
63
64
66
67
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
68
69
70
71
72
73
74
75
76
77
79
79
82
83
83
84
85
86
87
88
89
90
92
92
95
98
104
104
106
108
108
110
111
113
114
117
120
122
124
127
129
131
133
137
138
142
148
149
149
150
150
151
151
152
152
152
153
153
154
155
156
156
157
158
159
159
160
160
161
163
163
165
165
166
167
168
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
169
169
170
171
172
172
173
174
175
176
176
177
178
178
180
182
183
185
186
188
190
191
192
193
194
198
198
199
199
200
200
201
202
203
203
204
205
206
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
207
207
208
209
210
210
211
212
213
214
215
216
217
218
221
224
227
229
231
233
236
238
240
242
243
245
247
247
248
249
249
250
251
251
List of Figures
2.1
7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8
7.9
7.10
7.11
7.12
7.13
7.14
7.15
7.16
7.17
7.18
7.19
7.20
7.21
7.22
7.23
7.24
7.25
7.26
7.27
root locus . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . .
stability using Nyquist criterion . .
stability using Nyquist criterion . .
stability using Nyquist criterion . .
stability using Nyquist criterion . .
stability using Nyquist criterion . .
stability using Nyquist criterion . .
stability using Nyquist criterion . .
stability using Nyquist criterion . .
Phase Margin . . . . . . . . . . . .
stability using Nyquist criterion . .
gain phase plot . . . . . . . . . . .
stability using bode plot . . . . . .
gain margin and phase margin . . .
stability using bode plot . . . . . .
root locus description . . . . . . . .
root locus description . . . . . . . .
root locus description . . . . . . . .
root locus . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . .
root locus . . . . . . . . . . . . . .
Overall Transfer Function and Root
root locus . . . . . . . . . . . . . .
10
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
Locus
. . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
22
80
81
82
91
93
94
96
97
99
100
102
103
105
107
109
110
112
113
115
118
120
123
125
127
130
132
134
8.1
8.2
8.3
8.4
8.5
8.6
design
design
design
design
design
design
suitable compensator .
suitable compensator .
phase lead compensator
phase lead compensator
suitable compensator .
suitable compensator .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
139
140
142
143
146
147
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
164
179
181
182
184
185
187
189
190
191
192
195
196
197
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
217
219
220
222
223
225
226
228
229
232
234
236
238
240
242
244
11
12
246
Chapter 1
INTRODUCTION
// C a p t i o n : i n v e r s e l a p l a c e t r a n s f o r m
// e x a m p l e 1 . 6 . 1 . ( i )
// p a g e 7
// F ( s ) =1/( s ( s +1) )
s = %s ;
syms t ;
[ A ]= pfss (1/(( s ) *( s +1) ) ) // p a r t i a l f r a c t i o n o f F ( s )
F1 = ilaplace ( A (1) ,s , t )
F2 = ilaplace ( A (2) ,s , t )
F = F1 + F2 ;
disp (F , f ( t )= ) // r e s u l t
// C a p t i o n : i n v e r s e l a p l a c e t r a n s f o r m
// e x a m p l e 1 . 6 . 1 . ( i i )
// p a g e 7
// F ( s )=s +6/( s ( s 2+4 s +3) )
13
5 s = %s ;
6 syms t ;
7 [ A ]= pfss (( s +6) /( s *( s ^2+4* s +3) ) ) // p a r t i a l
8
9
10
11
12
13
o f F( s )
A (1) =2/ s ;
F1 = ilaplace ( A (1) ,s , t )
F2 = ilaplace ( A (2) ,s , t )
F3 = ilaplace ( A (3) ,s , t )
F = F1 + F2 + F3 ;
disp (F , f ( t )= ) // r e s u l t
14
fraction
disp (F , f ( t )= ) // r e s u l t
fraction of
F( s )
8 F1 = ilaplace ( A (1) ,s , t )
9 F2 = ilaplace ( A (2) ,s , t )
10 F = F1 + F2 ;
11 disp (F , f ( t )= ) // r e s u l t
5
6
7
8
9
10
// C a p t i o n : p r o g r a m l a p l a c e t r a n s f o r m
// e x a m p l e 1 . 6 . 1 . ( v )
// p a g e 9
// t h i s p r o b l e m i s s o l v e d i n two p a r t s b e c a u s e i n
t h i s p r o b l e m p f s s f u n c t i o n d o n o t work . So , F i r s t
we f i n d p a r t i a l f r a c t i o n u s i n g method a s we do i n
maths and t h e n s e c o n d l y we f i n d i n v e r s e l a p l a c e
transform as usual .
// p a r t i a l f r a c t i o n
s = %s
syms t ;
num =( s ^2+2* s +3) ;
den =( s +2) ^3;
g = syslin ( c , num / den ) ;
15
11
12
13
14
15
16
17
18
19
20
21
22
rd = roots ( den ) ;
[ n d k ]= factors ( g )
a (3) = horner ( g * d (1) ^3 , rd (1) )
a (2) = horner ( derivat ( g * d (1) ^3) , rd (1) )
a (1) = horner ( derivat ( derivat ( g * d (1) ^3) ) , rd (1) )
// i n v e r s e l a p l a c e
// p a r t i a l f r a c t i o n w i l l be : a ( 1 ) / ( s +1)+a ( 2 ) / ( ( s +2)
2 )+a ( 3 ) / ( ( s +2) 3 )
F1 = ilaplace (1/ d (1) ,s , t )
F2 = ilaplace ( -2/( d (1) ^2) ,s , t )
F3 = ilaplace (2*1.5/( d (1) ^3) ,s , t )
F = F1 + F2 + F3
disp (F , f ( t )= ) // r e s u l t
// C a p t i o n : s o l u t i o n o f d i f f e r e n t i a l e q u a t i o n
// e x a m p l e 1 . 6 . 2
// p a g e 9
// a f t e r t a k i n g l a p l a c e t r a n s f o r m and a p p l y i n g g i v e n
c o n d i t i o n , we g e t :
//X( s ) =2 s +5/( s ( s +4) )
s = %s ;
syms t
[ A ]= pfss ((2* s +5) /( s *( s +4) ) )
A (1) =1.25/ s
F1 = ilaplace ( A (1) ,s , t )
F2 = ilaplace ( A (2) ,s , t )
f = F1 + F2 ;
disp (f , f ( t )= ) // r e s u l t
1
2
3
4
5
6
7
8
9
// C a p t i o n : s o l u t i o n o f d i f f e r e n t i a l e q u a t i o n
// e x a m p l e 1 . 6 . 3
// p a g e 10
// a f t e r t a k i n g l a p l a c e t r a n s f o r m and a p p l y i n g g i v e n
c o n d i t i o n , we g e t :
//X( s ) =1/( s 2+2 s +2)
s = %s ;
syms t
f = ilaplace (1/( s ^2+2* s +2) ,s , t ) ;
disp (f , f ( t )= ) // r e s u l t
// C a p t i o n : s o l u t i o n o f d i f f e r e n t i a l e q u a t i o n
// e x a m p l e 1 . 6 . 4
// p a g e 10
// a f t e r t a k i n g l a p l a c e t r a n s f o r m and a p p l y i n g g i v e n
c o n d i t i o n , we g e t :
//Y( s ) =(6 s +6) / ( ( s 1) ( s +2) ( s +3) )
s = %s ;
syms t
[ A ]= pfss ((6* s +6) /(( s -1) *( s +2) *( s +3) ) )
F1 = ilaplace ( A (1) ,s , t )
F2 = ilaplace ( A (2) ,s , t )
F3 = ilaplace ( A (3) ,s , t )
F = F1 + F2 + F3 ;
disp (F , f ( t )= ) // r e s u l t
// C a p t i o n : i n i t i a l v a l u e
// e x a m p l e 1 . 6 . 5
// p a g e 11
17
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// I ( s ) =(C s / ( RCs+1) ) E( s )
// g i v e n : E( s ) =100/ s , R=2 megaohm ,C=1 uF
// so , I ( s ) =(((1 10 6) s ) / ( 2 s +1) ) ( 1 0 0 / s )
syms t
p = poly ([0 10^ -6] , s , c o e f f ) ;
q = poly ([1 2] , s , c o e f f ) ;
r = poly ([0 1] , s , c o e f f ) ;
F1 = p / q ;
F2 =1/ r ;
F = F1 * F2
f = ilaplace (F ,s , t ) ;
z = limit (f ,t ,0) ; // i n i t i a l v a l u e t h e o r e m
z = dbl ( z ) ;
disp (z , i (0+)= )
// C a p t i o n : f i n a l v a l u e
// e x a m p l e 1 . 6 . 7
// p a g e 12
//X( s ) =100/( s ( s 2+2 s +50) )
p = poly ([100] , s , c o e f f ) ;
q = poly ([0 50 2 1] , s , c o e f f ) ;
F=p/q;
syms s
x=s*F;
y = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m
y = dbl ( y )
disp (y , x ( i n f )= ) // r e s u l t
// C a p t i o n : s t e a d y s t a t e v a l u e
18
2
3
4
5
6
7
8
9
10
11
12
// e x a m p l e 1 . 6 . 7
// p a g e 12
//X( s )=s / ( s 2 ( s 2+6 s +25) )
p = poly ([0 1] , s , c o e f f ) ;
q = poly ([0 0 25 6 1] , s , c o e f f ) ;
F=p/q;
syms s
x=s*F;
y = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m
y = dbl ( y )
disp (y , x ( i n f )= ) // r e s u l t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
21 y2 = limit ( f2 ,t ,0) ; // i n i t i a l v a l u e t h e o r e m
22 y2 = dbl ( y2 ) ;
23 disp ( y2 , f d o u b l e p r i m e (0+)= )
// C a p t i o n : f i n a l v a l u e
// e x a m p l e 1 . 6 . 1 0
// p a g e 13
syms t s ;
F =4/( s ^2+2* s )
x=s*F
x = simple ( x )
z = limit (x ,s ,0) ; // f i n a l v a l u e t h e o r e m
z = dbl ( z ) ;
disp (z , f (0+)= )
20
Chapter 2
TRANSFER FUNCTIONS
// C a p t i o n : p o l e z e r o P l o t
// e x a m p l e 2 . 4 . 1
// p a g e 19
// t r a n s f e r f u n c t i o n :G( s ) = ( 1 / 2 ( ( s 2+4) ( 1 + 2 . 5 s ) ) / ( ( s
2+2) ( 1 + 0 . 5 s ) ) )
s = %s ;
G = syslin ( c ,(1/2*(( s ^2+4) *(1+2.5* s ) ) /(( s ^2+2)
*(1+0.5* s ) ) ) ) ;
disp (G , G( s )= ) ;
x = plzr ( G )
xtitle ( p o l e z e r o c o n f i g u r a t i o n , R e a l p a r t ,
Img part );
// v a l u e a t s =2
a =2;
g =(1/2*(( a ^2+4) *(1+2.5* a ) ) /(( a ^2+2) *(1+0.5* a ) ) ) ;
disp (g , G( 2 )= ) ;
21
22
function
10 G = K * g ; // t r a n s f e r f u n c t i o n
11 disp (G , G( s )= ) ;
12 //G( s ) =3.2 a t s =1;
13 // on s o l v i n g we f i n d K=12
14 K =12;
15 G = K * g ;
16 disp (G , G( s )= )
23
Chapter 3
BLOCK DIAGRAMS
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 1
// p a g e 32
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 H1 ;
// s h i f t i n g t a k e o f f p o i n t a f t e r b l o c k G2 t o a
p o s i t i o n b e f o r e b l o c k G2
a = G2 * H1 ;
b = parallel ( G2 , G3 ) ;
// s h i f t i n g t a k e o f f p o i n t b e f o r e ( G2+G3 ) t o A f t e r (
G2+G3 )
c=a/b;
m =1;
d = b /(1+ m * b ) ;
e = series ( G1 , d ) ;
y =( e /(1+ c * e ) ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= ) ;
24
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 2
// p a g e 34
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 H1 ;
// s h i f t i n g t a k e o f f p o i n t b e f o r e b l o c k G1 t o a
p o s i t i o n a f t e r b l o c k G1
a = G1 * H1 ;
b = parallel ( G1 , G2 ) ;
c = G3 /. a
y = series (b , c ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= )
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
25
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 3
// p a g e 35
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 G5 G6 H1 H2 ;
// s h i f t t h e t a k e o f p o i n t p l a c e d b e f o r e G2 t o w a r d s
r i g h t s i d e o f b l o c k G2
a = G5 / G2 ;
b = parallel ( G3 , G4 ) ;
c = series (b , G6 ) ;
d = parallel (a , c ) ;
e = series ( G1 , G2 ) ;
l = series ( H1 , d ) ;
g = e /. H2
y = g /(1+ g * l )
y = simple ( y ) ;
disp (y , C( s ) /R( s )= )
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 4
// p a g e 36
26
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 H1 H2 ;
// s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G1 t o a f t e r
b l o c k G1
a = G3 / G1 ;
b = parallel (a , G2 ) ;
// s h i f t t h e t a k e o f f p o i n t b e f o r e b l o c k b t o w a r d s
r i g h t s i d e o f same b l o c k
c =1/ b ;
d = series ( H1 , c ) ;
e = series ( G1 , b ) ;
g = parallel ( H2 , d ) ;
y = e /(1+ e * g ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= )
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
1
2
3
4
27
8
9
10
11
12
13
14
15
16
17
18
// s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G3 t o a f t e r
b l o c k G3
a = H3 / G3 ;
b = G3 /. H2 ;
c = series ( G2 , b ) ;
// s h i f t t h e summing p o i n t a f t e r b l o c k G1 t o b e f o r e
b l o c k G1
d = a / G1 ;
e = G1 /. H1 ;
f = series (e , c ) ;
y = f /(1+ f * d ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= )
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 6
// p a g e 38
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 H1 ;
a = parallel ( G1 , G3 ) ;
b = G2 /. H1 ;
y = series (a , b ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= ) ;
28
11
12
13
14
15
16
17
18
19
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 7
// p a g e 39
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 H1 H2 ;
// s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G2 t o a f t e r
b l o c k G2
a = G2 * H1 ;
// s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G2 t o a f t e r
b l o c k G1 and s h i f t t h e summing p o i n t b e f o r e
b l o c k G2 t o b e f o r e b l o c k G2
// i n t e r c h a n g e c o n s e c u t i v e summing p o i n t and s h i f t
t h e t a k e o f f p o i n t p l a c e d b e f o r e H2 t o a f t e r
b l o c k H2
b = G2 * H2 ;
c = b * H1 ;
d = parallel ( G3 , G2 ) ;
e =1/. b
f = series (d , e ) ;
g = G1 /. a
h = series (g , f ) ;
y = h /(1 - h * c ) ;
29
20 y = simple ( y ) ;
21 disp (y , C( s ) /R( s )= )
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 8
// p a g e 41
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 G5 H1 H2 ;
// s h i f t t h e summing p o i n t b e f o r e b l o c k G5 t o w a r d s
l e f t o f b l o c k G5
a = G2 * G5 ;
b = G4 /. H1 ;
c = series ( G5 , H2 ) ;
d = series (b , G3 ) ;
e = d /(1+ d * c ) ;
e = simple ( e )
f = parallel ( G1 , a ) ;
y = series (f , e ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= ) ;
check Appendix AP 2 for dependency:
parallel.sce
30
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 9
// p a g e 42
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 G5 H1 H2 H3 ;
// s h i f t t h e t a k e o f f p o i n t p l a c e d b e f o r e G3 t o a f t e r
b l o c k G3
a = G5 / G3 ;
b = G1 /. H1 ;
c = series (b , G2 ) ;
d = G3 /. H2 ;
e = parallel ( G4 , a ) ;
e = simple ( e ) ;
f = series (c , d ) ;
g = series (f , e ) ;
g = simple ( g ) ;
y = g /(1+ g * H3 ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= ) ;
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
31
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 1 0
// p a g e 43
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 G5 H1 H2 H3 ;
a = parallel ( G3 , G4 ) ;
// s h i f t o f f t h e t a k e o f f p o i n t b e f o r e b l o c k a t o
a f t e r block a
b =1/ a ;
d =1;
c = G2 /(1+ G2 * d ) ;
e = parallel ( H1 , b ) ;
f = series (c , a ) ;
g = series ( H2 , e ) ;
h = f /(1+ f * g ) ;
h = simple ( h ) ;
i = series (h , G1 ) ;
y = i /(1+ i * H3 ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= )
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
32
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 1 1
// p a g e 45
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 H1 H2 H3 ;
a = G4 /. H1 ;
// s h i f t t h e summing p o i n t a f t e r b l o c k G3 t o w a r d s
l e f t o f b l o c k G3
b = G2 / G3 ;
c = series (a , G3 ) ;
d = c /(1+ c * H2 ) ;
d = simple ( d )
// s h i f t t h e summing p o i n t b e f o r e b l o c k G1 t o w a r d s
r i g h t o f b l o c k G1
e = G1 * H3 ;
f = d /(1+ d * e ) ;
f = simple ( f )
g = parallel ( G1 , b ) ;
g = simple ( g ) ;
y = series (g , f )
y = simple ( y ) ;
disp (y , C( s ) /R( s )= ) ;
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 1 2
// p a g e 47
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 H1 H2 H3 ;
// s h i f t t h e summing p o i n t b e f o r e b l o c k G1 t o w a r d s
r i g h t o f b l o c k G1
// s h i f t t h e summing p o i n t a f t e r b l o c k G3 t o w a r d s
l e f t o f b l o c k G3
a = G2 / G1
b = H3 / G3 ;
c = G1 /. H1
d = G3 /. H2
e = series ( G4 , d )
// s h i f t t h e summing p o i n t a f t e r b l o c k e t o w a r d s l e f t
of block e
g =1/ e
f = series (a , g ) ;
f = simple ( f )
h = parallel (f ,1) ;
h = simple ( h )
i = e /(1+ e * b ) ;
i = simple ( i )
j = series (c , h ) ;
y = series (j , i ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= ) ;
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
34
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 1 3
// p a g e 49
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 H1 H2 ;
// s h i f t t h e summing p o i n t a f t e r b l o c k H2 t o w a r d s
r i g h t o f b l o c k H2
// s h i f t t h e summing p o i n t a f t e r b l o c k H1 t o w a r d s
r i g h t o f b l o c k H2
a = H1 * H2
b = parallel ( G1 , G2 )
c = G4 /. a
d = series ( G3 , c )
e = d /(1+ d * H2 ) ;
e = simple ( e )
f = series (b , e )
y = f /(1+ f * a ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= ) ;
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
35
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 1 4
// p a g e 50
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 G3 G4 H1 H2 R D ;
a = parallel ( G1 , G2 )
b = G3 /. H2
c = series (a , b )
// i n o r d e r t o d e t e r m i n e C( s ) /R( s ) c o n s i d e r D=0
d = series (c , G4 ) ;
y = d /(1+ d * H1 ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= )
// now c o n s i d e r R=0 f o r c a l c u l a t i n g C( s ) /D( s )
e = series (c , H1 )
z = G4 /(1+ G4 * e ) ;
z = simple ( z ) ;
disp (z , C( s ) /D( s )= ) ;
x =( y * R ) +( z * D ) ;
x = simple ( x ) ;
printf ( t o t a l o u t p u t ) ;
disp (x , C( s ) )
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 3 . 2 . 1 5
// p a g e 52
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
// e x e c p a r a l l e l . s c e ;
// e x e c s e r i e s . s c e ;
syms G1 G2 H1 H2 H3 D1 D2 R ;
a = G2 /. H2
b = a /(1+ a * H3 ) ;
b = simple ( b )
// i n o r d e r t o d e t e r m i n e C( s ) /R( s ) c o n s i d e r D1=0 ,D2=0
c = series (b , G1 )
y = c /(1+ c * H1 ) ;
y = simple ( y )
disp (y , C( s ) /R( s ) ) ;
// now c o n s i d e r R=0 ,D2=0 f o r c a l c u l a t i n g C( s ) /D1 ( s )
d = series ( G1 , H1 ) ;
z = b /(1+ b * d ) ;
z = simple ( z )
disp (z , D1 ( s ) /R( s ) ) ;
// now c o n s i d e r R=0 ,D1=0 f o r c a l c u l a t i n g C( s ) /D2 ( s )
e = G1 *( - H1 ) ;
f = series (b , e ) ;
x = f /(1+ f ) ;
x = simple ( x ) ;
disp (x , D2 ( s ) /R( s ) ) ;
out =( y * R ) +( z * D1 ) +( x * D2 ) ;
out = simple ( out ) ;
disp ( out , C( s ) ) ;
check Appendix AP 2 for dependency:
parallel.sce
check Appendix AP 1 for dependency:
series.sce
37
Chapter 4
SIGNAL FLOW GRAPHS
// C a p t i o n : o v e r a l l t r a n s m i t t a n c e
// e x a m p l e 4 . 3 . 1
// p a g e 63
syms G1 G2 H1 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
L1 = - G1 * H1 ;
L2 = - G2 * H1 ;
P1 = G1 ;
P2 = G2 ;
D1 =1;
D2 =1;
D =1 -( L1 + L2 ) ;
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y )
disp (Y , C( s ) /R( s )= )
38
// C a p t i o n : o v e r a l l t r a n s m i t t a n c e
// e x a m p l e 4 . 3 . 2
// p a g e 64
syms G1 G2 H1 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 ;
P2 = G2 ;
L1 = - G1 * H1 ;
D1 =1;
D2 =1;
D =1 -( L1 ) ;
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= )
// C a p t i o n : c l o s e d l o o p t r a n s f e r f u n c t i o n
// e x a m p l e 4 . 4 . 1
// p a g e 64
syms G1 G2 G3 H1 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 * G3 ;
P2 = G2 * G3 ;
L1 = - G3 * H1 ;
D1 =1;
D2 =1;
39
12 D =1 -( L1 ) ;
13 Y =( P1 * D1 + P2 * D2 ) / D ;
14 Y = simple ( Y )
15 disp (Y , C( s ) /R( s )= )
// C a p t i o n : o v e r a l l g a i n
// e x a m p l e 4 . 4 . 2
// p a g e 65
syms a b c d e f g h
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = a * b * c * d ;
P2 = a * g ;
L1 = f ;
L2 = c * e ;
L3 = d * h ;
// n o n t o u c h i n g l o o p s a r e L1L2 , L1L3
L1L2 = L1 * L2 ;
L1L3 = L1 * L3 ;
D1 =1;
D2 =1 - L2 ;
D =1 -( L1 + L2 + L3 ) +( L1L2 + L1L3 ) ;
D = simple ( D ) ;
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , x5 / x1 ) ;
Scilab code Exa 4.4.3 to find various signal flow graph parameter
40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// C a p t i o n :
to find various signal flow graph parameter
// e x a m p l e 4 . 4 . 3
// p a g e 66
syms a b c d e f g h ij
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
// s i x i n d e p e n d e n t p a t h
P1 = a * b * d
P2 = e * f * h
P3 = a * j * h
P4 = e * i * d
P5 = - e * i * c * j * h
P6 = - a * j * g * i * d
// 3 INDIVIDUAL LOOPS
L1 = - b * c
L2 = - f * g
L3 = - i * c * j * g
//NON TOUCHING LOOPS
L1L2 = L1 * L2
//PATH FACTORS
D3 =1; D4 =1; D5 =1; D6 =1
D1 =1 - L2
D2 =1 - L1
//GRAPH DETERMINANT
D =1 -( L1 + L2 + L3 ) +( L1L2 ) ;
D = simple ( D )
disp (D , g r a p h d e t e r m i n a n t= )
Scilab code Exa 4.4.4 Transfer function using mason gain formula
1
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n
s gain formula
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// e x a m p l e 4 . 4 . 4
// p a g e 67
syms G1 G2 G3 H1 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 * G2 *1;
P2 = G1 * G3 ;
L1 = G2 *( -1) ;
L2 = G3 *( -1) ;
L3 = - G1 * G2 * H1
D1 =1;
D2 =1;
D =1 -( L1 + L2 + L3 ) ;
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= )
Scilab code Exa 4.4.5 Transfer function using mason gain formula
1
2
3
4
5
6
7
8
9
10
11
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n
s gain formula
// e x a m p l e 4 . 4 . 5
// p a g e 68
syms G1 G2 G3 H1 H2 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 * G2 ;
P2 = G1 * G3 ;
L1 = - G2 * H2 ;
L2 = - G1 * G2 * H1 ;
L3 = G1 * G3 *( - H2 ) * G2 *( - H1 ) ;
42
12
13
14
15
16
17
18
19
L3 = simple ( L3 )
D1 =1;
D2 =1;
D =1 -( L1 + L2 + L3 ) ;
D = simple ( D )
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= )
Scilab code Exa 4.4.6 Transfer function using mason gain formula
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n
s gain formula
// e x a m p l e 4 . 4 . 6
// p a g e 69
syms G1 G2 G3 G4 H1 H2 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
// t o f i n d C/R c o n s i d e r D=0
P1 = G1 * G3 * G4 ;
P2 = G2 * G3 * G4 ;
L1 = - G3 * H1 ;
L2 = - G1 * G3 * G4 * H2 ;
L3 = - G2 * G3 * G4 * H2 ;
D1 =1;
D2 =1;
D =1 -( L1 + L2 + L3 ) ;
D = simple ( D )
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= )
43
Scilab code Exa 4.4.7 Transfer function using mason gain formula
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n
s gain formula
// e x a m p l e 4 . 4 . 7
// p a g e 70
syms G1 G2 G3 H1 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 * G3 * G4 ;
P2 = G1 *( - G2 ) ;
L1 = G3 * G4 *( -1) ;
L2 = G1 * G3 * H1 *( -1) ;
L3 = G1 * G3 * H1 *( -1) ;
L4 = G1 *( - G2 ) *( -1) * G3 * H1 *( -1) ;
L5 = G1 *( - G2 ) *( -1) * G3 * H1 *( -1) ;
L4 = simple ( L4 ) ;
L5 = simple ( L5 ) ;
D1 =1;
D2 =1;
D =1 -( L1 + L2 + L3 + L4 + L5 ) ;
D = simple ( D )
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= )
Scilab code Exa 4.4.8 Transfer function using mason gain formula
1
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n
s gain formula
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// e x a m p l e 4 . 4 . 8
// p a g e 70
syms G1 G2 G3 G4 G5 H1 H2 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 * G2 * G4 ;
P2 = G2 * G3 * G5 ;
P3 = G3 ;
L1 = - G4 * H1 ;
L2 = - G2 * G4 * H2 ;
L3 = - G2 * G5 * H2 ;
D1 =1;
D2 =1;
D3 =1 - L1 ;
D =1 -( L1 + L2 + L3 ) ;
D = simple ( D )
Y =( P1 * D1 + P2 * D2 + P3 * D3 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= )
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n
// e x a m p l e 4 . 4 . 9
// p a g e 71
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
exec parallel . sce ;
exec series . sce ;
syms G1 G2 G3 G4 H5 H1 H2 ;
// s h i f t t h e SUMMING p o i n t l o c s t e d a f t e r G3 t o w a r d s
l e f t o f b l o c k G3
a = G2 /. H1 ;
45
10
11
12
13
14
15
16
17
18
b = G5 / G3 ;
c = parallel (a , b ) ;
c = simple ( c ) ;
d = G3 /. H2 ;
e = series ( G1 , c ) ;
f = series (e , d ) ;
y = series ( G4 , f ) ;
y = simple ( y ) ;
disp (y , C( s ) /R( s )= )
Scilab code Exa 4.4.10 Transfer function using mason gain formula
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// C a p t i o n : t r a n s f e r f u n c t i o n u s i n g m a s o n
s gain formula
// e x a m p l e 4 . 4 . 1 0
// p a g e 72
syms G1 G2 G3 G4 G5 H1 H2 ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 * G2 * G3 * G4 ;
P2 = G1 * G5 * G4 ;
L1 = - G2 * H1 ;
L2 = - G3 * H2 ;
D1 =1;
D2 =1;
D =1 -( L1 + L2 ) ;
D = simple ( D )
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= )
46
Chapter 5
MODELLING A CONTROL
SYSTEM
// C a p t i o n : c a l c u l a t e r e f e r e n c e v o l t a g e V r
// e x a m p l e 5 . 9 . 4
// p a g e 102
exec series . sce ;
A =2 // a m p l i f i e r
K =10 // m o t o r f i e l d
N =100 // s p e e d
tg =0.1 // t a c h o g e n e r a t o r
a = series (A , K ) ;
b = a /. tg ;
disp (b , N/ Vr= ) ;
// s i n c e N=100
Vr = N *(1/ b ) ;
disp ( Vr , r e f e r e n c e v o l t a g e = ) ;
check Appendix AP 1 for dependency:
series.sce
47
10
11
12
13
14
15
16
17
// C a p t i o n : c a l c u l a t e r e f e r e n c e v o l t a g e V r
// e x a m p l e 5 . 9 . 5
// p a g e 102
exec series . sce ;
Vt =250 // o u t p u t v o l t a g e
Rf =100 // f i e l d w i n d i n g r e s i s t a n c e
Kg =500 // g e n e r a t o r c o n s t a n t
A =2 // a m p l i f i e r
Vf =0.4 //
fraction of output voltage compared with reference voltage
a =1/ Rf ;
b = series (A , a ) ;
c = series (b , Kg ) ;
d = c /. Vf ;
disp (d , Vt / Vr= ) ;
// s i n c e Vt=250
Vr = Vt *(1/ d ) ;
disp ( Vr , r e f e r e n c e v o l t a g e = ) ;
check Appendix AP 1 for dependency:
series.sce
1
2
3
4
5
48
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
If =1.5; // f i e l d c u r r e n t
Kg = Ei / If ; // g e n e r a t o r e m f c o n s t a n t
Vt =400;
// from s t e d y s t a t e eq . we g e t : Vt / Ei=Rl / ( Rl+Ra )
a = Rl /( Rl + Ra ) ;
a = Vt / Ei ;
c =( Kg * a ) ;
G =( Ka * c ) ;
H =0.1;
// t r a n s f e r f u n c t i o n r e l a t i n g e r r o e e and t h e
r e f e r e n c e v o l t a g e Er i s e / Er =1/(1+GH)
b = e / Er ;
b =1/(1+ G * H ) ;
e = Vt * H *.02 ; // s i n c e a l l o w a b l e e r r o r i s 2%
Er =( Vt * H ) + e ;
// s i n c e e / Er =1/(1+GH) , on p u t t i n g v a l u e o f e , Er ,G
and H and s o l v i n g we g e t
Ka =1.89;
disp ( Ka , g a i n o f a m p l i f i e r K a = ) ;
// C a p t i o n : t r a n s f e r f u n c t i o n o f g e n e r a t o r
// e x a m p l e 5 . 9 . 7
// p a g e 105
syms E Vf Kg R L
s = %s ;
// g e n e r a t o r f i e l d c o n s t a n t K g =d e l t a ( e ) / d e l t a ( I f )
Kg =50/2;
L =2; // f i e l d i n d u c t a n c e
R =200; // f i e l d r e s i s t a n c e
// t r a n s f e r f u n c t i o n i s g i v e n by : E/ Vf=(Kg/R+s L )
a = Kg /( R + s * L ) ;
disp (a , E( s ) / Vf ( s )= ) ;
49
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m
// e x a m p l e 5 . 9 . 8
// p a g e 105
syms Rf Ra Kb Jm Lf La Kg Kt Jl s
Rf =1000; // f i e l d r e s i s t a n c e
Lf =100; // f i e l d i n d u c t a n c
Kg =1000; // g e n e r a t o r f i e l d c o n s t a n t
Ra =20; // a r m a t u r e r e s i s t a n c e
La =0.1; // a r m a t u r e i n d u c t a n c e
Kt =1.2; // m o t o r t o r q u e c o n s t
Kb =1.2; // m o t o r b a c k e m f c o n s t
Jl =0.00003; // m o m e n t o f i n e r t i a
Jm =0.00002; // c o e f f o f v i s c o u s f r i c t i o n
a = Kt /( Ra + s * La ) ;
b =1/(( Jm + Jl ) * s ) ;
c =( a * b ) ;
d = c /(1+ c * Kb ) ;
e = Kg /( Rf + s * Lf ) ;
f =( d * e ) ;
f = simple ( f )
disp (f , wss ( s ) / Vf ( s )= ) ;
// s t e a d y s t a t e v a l u e
disp ( u n d e r s t e a d y s t a t e c o n d i t i o n , on p u t t i n g s =0
i n e x p r e s s i o n f , we g e t : )
25 disp ( Vf =1.2 wss )
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m
50
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// e x a m p l e 5 . 9 . 9
// p a g e 107
syms Ka Ke Kt J f N1 N2
s = %s ;
Ke =10; // e r r o r d e t e c t o r g a i n
Ka =100; // a m p l i f i e r t r a n s c o n d u c t a n c e
Kt =.0005; // m o t o r t o r q u e c o n s t
J =.0000125; // m o m e n t o f i n e r t i a
f =.0005; // c o e f f o f v i s c o u s f r i c t i o n
g = N1 / N2 ;
g =1/20;
a =( Ka * Ke ) ;
b =( a * Kt ) ;
c =1/( J * s ^2+ f * s ) ;
d =( c * b ) ;
e =( g * d ) ;
h = e /(1+ e ) ;
disp (h , C( s ) /R( s )= ) ; // r e s u l t
6
7
8
9
10
11
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m
// e x a m p l e 5 . 9 . 1 0
// p a g e 108
syms Ra Kt Jm fm Kb
// where Ra=a r m a t u r e r e s i s t a n c e ; Kt=
m o t o r t o r q u e c o n s t ; Jm=m o m e n t o f i n e r t i a ; fm=
c o e f f o f v i s c o u s f r i c t i o n ; Kb=
motor back emf const
s = %s ;
a = Kt /( s * Ra *( s * Jm + fm ) ) ;
a = simple ( a ) ;
b = s * Kb ;
c = a /(1+ a * b ) ;
c = simple ( c ) ;
51
12
13
14
15
16
17
disp (c , Q( s ) /V( s )= ) ; // o v e r a l l t r a n s f e r f u n c t i o n
Kt =0.183; Kb =0.183; Ra =4.8; Jm =.004; fm =0.0015;
a = Kt /( s * Ra *( s * Jm + fm ) ) ;
b = s * Kb ;
c = a /(1+ a * b ) ;
disp (c , Q( s ) /V( s )= ) ; //
overall transfer function after substituting
v a l u e i n above e q u a t i o n
// C a p t i o n :
overall transfer function of positional control system
2
3
4
5
// e x a m p l e 5 . 9 . 1 1
// p a g e 109
syms Ka Ke Kb Kt Jeq feq Ra N1 N2
// where Ka= a m p l i f i e r g a i n ; Ke= e r r o r d e t e c t o r g a i n ;
Kb=m o t o r b a c k e m f c o n s t ; Kt=m o t o r t o r q u e c o n s t ;
Jeq=m o m e n t o f i n e r t i a ;
Ra=a r m a t u r e r e s i s t a n c e ;
f e q= c o e f f o f v i s c o u s f r i c t i o n ;
s = %s ;
Kt =.0001; Ra =0.2; Jeq =.0001; feq =.0005; Ka =10; Ke =2; Kb
=0.0001; f =0.1;
a =( Ka * Ke ) ; // i n s e r i e s
b = Kt /( s * Ra *( Jeq * s + feq ) ) ;
c = b /(1+ b * s * Kb ) ;
d =( a * c ) ; // i n s e r i e s
f =0.1;
g =( d * f ) ; // i n s e r i e s
h = g /(1+ g ) ;
disp (h , C( s ) /R( s )= ) ; //
overall transfer function after substituting
v a l u e i n above e q u a t i o n
6
7
8
9
10
11
12
13
14
15
52
6
7
8
9
10
11
12
13
14
15
16
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n o f g i v e n s y s t e m
// e x a m p l e 5 . 9 . 1 2
// p a g e 111
syms Ka Ke Kf Rf Lf Jeq feq N1 N2
// where Ka= a m p l i f i e r g a i n ; Ke= e r r o r d e t e c t o r g a i n ;
Kf=m o t o r t o r q u e c o n s t ; Rf= f i e l d r e s i s t a n c e ; L f=
f i e l d i n d u c t a n c e Jeq=m o m e n t o f i n e r t i a ; f e q=
coeff of viscous friction ;
s = %s ;
d = N1 / N2 ;
Ka =10; Ke =8; Kf =0.05; Rf =5; Lf =0.25; Jeq =0.05; feq
=0.075; d =0.1;
a =( Ka * Ke ) ;
b = Kf /( Rf + s * Lf ) ;
c =1/( s *( Jeq * s + feq ) ) ;
g =( b * c )
// i n s e r i e s
h =( g * a )
// i n s e r i e s
i =( h * d )
// i n s e r i e s
j = i /(1+ i ) ;
disp (j , C( s ) /R( s )= ) ;
Scilab code Exa 5.9.13 Overall Transfer Function of Two Phase ac Motor
1
2
3
4
5
// C a p t i o n :
overall transfer function of two phase ac motor
// e x a m p l e 5 . 9 . 1 3
// p a g e 113
syms Ka K Ktg Jeq feq N1 N2 m
// where Ka= a m p l i f i e r g a i n ; Ktg=t a c h o m e t e r g a i n c o n s t
Jeq=m o m e n t o f i n e r t i a ; f e q=
53
6
7
8
9
10
11
12
13
14
15
6
7
8
9
10
11
12
13
14
15
// C a p t i o n : t r a n s f e r f u n c t i o n o f m o t o r
// e x a m p l e 5 . 9 . 1 4
// p a g e 114
syms Kt Kb Ra La J
// where Ka= a m p l i f i e r g a i n ; Kt=m o t o r t o r q u e c o n s t ; Ra
=a r m a t u r e r e s i s t a n c e ; La=a r m a t u r e i n d u c t o r ; J=
moment of inertia
s = %s ;
// s i n c e t h e r e a r e two i n p u t s Va ( s ) and Tl ( s ) . I f Va ( s )
i s h e l d a t f i x e d v a l u e t h e n o n l y e f f e c t o f Tl ( s )
i s c o n s i d e r e d and Va ( s ) i s t a k e n a s Z e r o .
a =( Kt * Kb ) /( Ra + s * La )
b =1/ J * s
c = b /(1+ b * a ) ;
disp ( -c , Wm( s ) / Tl ( s )= ) ; // n e g a t i v e s i g n i n d i c a t e s
t h a t an i n c r e a s e i n Tl d e c r e a s e s Wm
Kb =9.55; Kt =9.55; Ra =0.75; La =0.005; J =50;
a =( Kt * Kb ) /( Ra + s * La )
b =1/( J ) *(1/( s ) )
c = b /(1+ b * a ) ;
54
16
disp ( -c , Wm( s ) / Tl ( s )= ) ; // a f t e r p u t t i n g v a l u e s
55
Chapter 6
TIME RESPONSE ANALYSIS
OF CONTROL SYSTEMS
// C a p t i o n : t i m e r e s p o n s e f o r s t e p f u n c t i o n
// e x a m p l e 6 . 1 0 . 1
// p a g e 170
// we have d e f i n e d p a r a l l e l and s e r i e s f u n c t i o n
which we a r e g o i n g t o u s e h e r e
exec parallel . sce ;
exec series . sce ;
s = %s ;
syms t ;
a =4/( s *( s +4) )
b = s +1.2
c = s +0.8
d = a /(1+ a )
e = parallel (b , c )
f = d /. e ;
disp (f , C( s ) /R( s )= ) ; // t r a n s f e r f u n c t i o n
// s i n c e i n p u t : r ( t ) =2 , s o R( s ) =2/ s ; / /
step function of magnitude 2
g = f *(2/ s ) ;
56
18 disp (g , C( s )= ) ;
19 [ A ]= pfss (8/( s *( s +2) *( s +6) ) )
20 F = ilaplace ((8/( s *( s +2) *( s +6) ) ) ,s , t ) ;
21 disp (F ,
Scilab code Exa 6.10.2 Time Response for unit Impulse and Step function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// C a p t i o n :
time response for unit impulse and step function
// e x a m p l e 6 . 1 0 . 2
// p a g e 171
//G( s ) =(4 s +1) / 4 ( s 2 ) ; H( s ) =1;
clc ;
s = %s ;
syms t ;
G =(4* s +1) /(4*( s ^2) ) //G( s )
b =1;
a = G /.( b ) ;
disp (a , C( s ) /R( s )= ) ;
// f o r u n i t i m p u l s e r e s p o n s e R( s ) =1 ; s o C( s )=a ;
disp ( f o r u n i t i m p u l s e r e s p o n s e R( s ) =1 ; s o C( s )=a ;
)
disp (a , C( s )= ) ;
c = ilaplace (a ,s , t ) ;
disp (c , c ( t )= ) ;
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s
disp ( f o r u n i t s t e p r e s p o n s e R( s ) =1/ s , s o ) ;
d = a *(1/ s ) ;
disp (d , C( s )= ) ;
e = ilaplace (d ,s , t ) ;
disp (e , c ( t )= ) ;
57
Scilab code Exa 6.10.3 Time Response for Unit Step Function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n
// e x a m p l e 6 . 1 0 . 3
// p a g e 172
//G( s ) =2/( s ( s +3)
clc ;
s = %s ;
syms t ;
G =2/( s *( s +3) ) //G( s )
b =1;
a = G /.( b ) ;
disp (a , C( s ) /R( s )= ) ;
disp ( f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ) ;
d = a *(1/ s ) ;
disp (d , C( s )= ) ;
e = ilaplace (d ,s , t ) ;
disp (e , c ( t )= ) ;
Scilab code Exa 6.10.4 Time Response for Unit Step Function
1
2
3
4
5
6
7
8
9
10
11
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n
// e x a m p l e 6 . 1 0 . 4
// p a g e 172
s = %s ;
syms t ;
a =( s +4) ;
b =1/( s *( s +2) ) ;
c =( a * b ) ; // i n s e r i e s
d =0.5;
e = c /. d
f =1;
58
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
g = e /. f ;
disp (g , C( s ) /R( s )= ) ;
disp ( f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ,
so );
h = g *(1/ s ) ;
disp (h , C( s )= ) ;
[ A ]= pfss ( h ) ;
A (1) =(1/ s )
F1 = ilaplace ( A (1) ,s , t )
//A( 2 ) can be w r i t t e n a s : A( 2 )=a1+a2
a1 = -1/(4*(6+3.5* s + s ^2) ) ;
a2 =( -( s +1.75) /(6+3.5* s + s ^2) ) ;
F2 = ilaplace ( a1 ,s , t ) ;
F3 = ilaplace ( a2 ,s , t ) ;
// now m u l t i p l y i n g by t h e i r c o e f f i c i e n t
F1 =(2/3) * F1 ;
F2 =(1/6) * F2 ;
F3 =(2/3) * F3 ;
// a f t e r a d d i n g F1 , F2 and F3 and s i m p l y f y i n g we g e t
t i m e r e s p o n s e which i s d e n o t e d by c ( t )
30 disp ( c ( t ) =((2 (%e ( 1 . 7 5 t ) ( 2 c o s ( 1 . 7 1 t ) 0.29 s i n
( 1 . 7 1 t ) ) ) ) /3 ) ; // t i m e r e s p o n s e
f u n c t i o n i n forward path
8 H =1; // backward p a t h t r a n s f e r f u n c t i o n
9 a = G /. H // c l o s e d l o o p t r a n s f e r f u n c t i o n
10 b = denom ( a )
59
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
c = coeff ( b )
//Wn2= c ( 1 , 1 )
Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y
disp ( Wn , n a t u r a l f r e q u e n c y ,Wn= )
// 2 z e t a Wn=c ( 1 , 2 )
zeta = c (1 ,2) /(2* Wn ) // damping r a t i o
disp ( zeta , damping r a t i o , z e t a= )
Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y
disp ( Wd , damping r a t i o ,Wd= )
Tp = %pi / Wd // peak t i m e
disp ( Tp , peak time , Tp= )
Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max .
overshoot
disp ( Mp , max o v e r s h o o t , Mp= )
t =(2* %pi ) /( Wn * sqrt (1 - zeta ^2) ) // p e r i o d o f o s c i l l a t i o n
disp (t , t i m e a t which f i r s t o v e r s h o o t o c c u r s= )
disp (t , p e r i o d o f o s c i l l a t i o n , t= )
ts =4/( zeta * Wn ) // s e t t l i n g t i m e
disp ( ts , s e t t l i n g time , t s= )
N = Wd /(2* %pi ) * ts // no . o f o s c i l l a t i o n s c o m p l e t e d
before reaching steady state
disp (N , no . o f o s c i l l a t i o n s c o m p l e t e d b e f o r e
r e a c h i n g s t e a d y s t a t e , N= )
// C a p t i o n : t i m e r e s p o n s e
// e x a m p l e 6 . 1 0 . 6
// p a g e 174
// Kt=t o r q u e c o n s t a n t , J=moment o f i n e r t i a , f= c o e f f . o f
viscous friction
clc ;
syms Kt J f t
s = %s ;
Kt =360 , J =10 , f =60
60
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
b =1/( J * s ^2+ f * s ) ;
G =( Kt * b ) // i n s e r i e s
H =1; // backward p a t h t r a n s f e r f u n c t i o n
cl = G /. H ; // c l o s e d l o o p t r a n s f e r f u n c t i o n
d = denom ( cl ) /10; // t a k i n g 10 common from n u m e r a t o r and
denominator f o r s i m p l y f y i n g
closed loop transfer function
f = numer ( cl ) /10;
CL = f / d ; //
closed loop transfer function after simplifying
printf ( o v e r a l l t r a n s f e r f u n c t i o n= \n ) ;
disp ( CL , C( s ) /R( s )= ) ;
// g i v e n R( s ) =( 50 ( %pi / 1 8 0 ) ) ( 1 / s ) ;
R =(50*( %pi /180) ) *(1/ s ) ;
C = R * CL ;
e = coeff ( d )
//Wn2= e ( 1 , 1 )
Wn = sqrt ( e (1 ,1) ) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=c ( 1 , 2 )
zeta = e (1 ,2) /(2* Wn ) // damping r a t i o
// c ( t ) : t i m e r e s p o n s e e x p r e s s i o n
c =(5* %pi /18) *(1 -( exp ( - zeta * Wn * t ) * sin ( Wn * sqrt (1 - zeta
^2) * t + atan ( sqrt (1 - zeta ^2) / zeta ) ) ) / sqrt (1 - zeta ^2) )
;
c = float ( c )
disp (c , c ( t )= )
// c a p t i o n :
determine factor by which K should be reduced
// e x a m p l e 6 . 1 0 . 7
// p a g e 175
syms T K //K=f o r w a r d p a t h g a i n , T=t i m e c o n s t a n t
s = %s ;
61
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
G = K /( s *( s * T +1) ) ;
G = simple ( G ) ;
printf ( t h e f o r w a r d p a t h t r a n s f e r f u n c t i o n : \n ) ;
disp (G , G( s )= ) ;
H =1; // backward p a t h t r a n s f e r f u n c t i o n
CL = G /. H ;
CL = simple ( CL ) ;
printf ( t h e o v e r l a l l t r a n s f e r f u n c t i o n : \n ) ;
disp ( CL , C( s ) /R( s )= ) ;
printf ( t h e c h a r a c t e r s t i c e q u a t i o n i s : \ n ) ;
disp ( s 2+ s /T+K/T=0 ) ;
// from c h a r . eq . we g e t Wn2=K/T and 2 z e t a Wn=1/T ,
so
Wn = sqrt ( K / T ) ; // n a t u r a l f r e q u e n c y
zeta =(1/2) * sqrt (1/ K * T )
// l e t K1 be f o r w a r d p a t h g a i n when Mp1=60% and z e t a 1
be c o r r e s p o n d i n g damping f a c t o r
syms K1 K2 zeta1 zeta2
Mp1 =( exp ( -( zeta1 * %pi ) / sqrt (1 - zeta1 ^2) ) ) *100 //max .
overshoot
// on s o l v i n g we g e t :
zeta1 =0.158
// s i m i l a r l y l e t K2 be f o r w a r d p a t h g a i n when Mp2=20%
and z e t a 2 be c o r r e s p o n d i n g damping f a c t o r , which
gives
zeta2 =0.447
// a s s u m i n g t i m e c o n s t . T t o be c o n s t . we g e t
k =( K1 / K2 ) ;
k =( zeta1 / zeta2 ) ^2;
disp (k , K1/K2= ) ;
Scilab code Exa 6.10.8 Determine Steady State Speed and Error
1
2
// c a p t i o n : d e t e r m i n e s t e a d y s t a t e s p e e d a n d e r r o r
// e x a m p l e 6 . 1 0 . 8
62
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// p a g e 176
//Tm=t o r q u e c o n s t a n t , J=moment o f i n e r t i a , f= c o e f f . o f
v i s c o u s f r i c t i o n , E=e r r o r d e t e c t o r g a i n
syms Tm J f t E s
Tm =75; J =10; f =5; E =1;
a =( Tm * E ) ;
b =1/( J * s + f ) ;
c =( a * b ) ;
H =1; // backward p a t h t r a n s f e r f u n c t i o n
CL = c /. H ;
printf ( t h e o v e r l a l l t r a n s f e r f u n c t i o n : \n ) ;
disp ( CL , Wo( s ) /Wr( s )= ) ;
// s i n c e Wr( s ) =(2 %pi ) ( 1 / s )
q = bfloat ((2* %pi ) ,2)
Wr = q *(1/ s )
Wo = CL * Wr ;
wo = ilaplace ( Wo ,s , t )
printf ( e x p r e s s i o n r e l a t i n g l o a d s p e e d a n d t i m e : \ n )
;
disp ( wo , wo ( t )= ) ;
a = Wo * s
Woss = limit (a ,s ,0) ; // s t e a d y s t a t e s p e e d
Woss = dbl ( Woss ) ;
disp ( Woss , s t e a d y s t a t e s p e e d= ) ;
We = Wr *(10* s +5) /(10* s +80) ;
Wess = limit ( s * We ,s ,0) ; // s t e a d y s t a t e e r r o r
Wess = dbl ( Wess ) ;
disp ( Wess , s t e a d y s t a t e e r r o r= ) ;
// c a p t i o n : d e t e r m i n e J , f , K
// e x a m p l e 6 . 1 0 . 9
// p a g e 178
// J=moment o f i n e r t i a , f=C , K=f o r w a r d p a t h g a i n ,Wn=
63
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
n a t u r a l f r e q u e n c y , z e t a=damping r a t i o
syms J f K s zeta Wn
CL =1/( J * s ^2+ f * s + K ) ;
printf ( g i v e n : t r a n s f e r f u n c t i o n i s : \ n ) ;
disp ( CL , t h e t a ( s ) /T( s )= ) ;
T =10*(1/ s ) ;
theta = T * CL ;
theta_ss = limit ( s * theta ,s ,0) // s t e a d y s t a t e v a l u e
printf ( g i v e n : t h e t a s s =0.5\ n s o K= 1 0 / 0 . 5 ) ;
theta_ss =0.5;
K =10/ theta_ss ;
disp (K , f o r w a r d p a t h g a i n , K= ) ;
Mp =0.06; //max . peak o v e r s h o o t ( g i v e n )(1)
Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) //(2)
// from eq . ( 1 ) and ( 2 ) , we g e t
zeta =0.66;
tp = %pi /( Wn *( sqrt (1 - zeta ^2) ) ) ; //(3)
tp =1 // ( g i v e n )
Wn = %pi /( tp * sqrt (1 - zeta ^2) ) ;
// a l s o Wn=s q r t (K/ J ) ;
J = K / Wn ^2;
// a l s o 2 z e t a Wn=f / J
f = J *2* zeta * Wn ;
disp (J , moment o f i n e r t i a , J= ) ;
disp (f , moment o f i n e r t i a , f= ) ;
1
2
3
4
64
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Ke =5.73;
Km =0.045;
n = sym ( N1/N2 )
n = subs (n , N1/N2 ,1/10) ;
J =0.25* float ( n ^2) ; // r e f e r r e d t o motor s i d e
f =1* float ( n ^2) ; // r e f e r r e d t o motor s i d e
// from t h e b l o c k d i a g r a m g i v e n i n f i g 6 . 1 0 . 6 on p a g e
179 ,
a =( Ke * Km )
b =1/( J * s ^2+ f * s )
c =( b * float ( a ) )
G =( n * c ) ;
G = simple ( G )
H =1;
d =(1+ G * H ) ;
d = simple ( d ) ;
CL = G / d ;
CL = simple ( CL )
disp ( CL , C( s ) /R( s )= ) ;
e = poly ([328800 127516 31879] , s , c o e f f )
printf ( t h e c h a r a c t e r s t i c s eq . i s : \ n ) ;
disp ( e ) ;
f = coeff ( e )
Wn = sqrt (( f (1 ,1) / f (1 ,3) ) ) // n a t u r a l f r e q u e n c y
zeta =(( f (1 ,2) / f (1 ,3) ) /(2* Wn ) ) // damping r a t i o
// p a r t ( b )
syms Td
g =1+ s * Td
h =( g * G )
i =1+ h * H
i = simple ( i ) ;
CL2 =( h / i )
CL2 = simple ( CL2 ) ;
disp ( CL2 , C( s ) /R( s )= ) ;
poly (0 , s ) ;
l = s ^2+(10.32* Td +4) * s +10.32;
printf ( on s i m p l y f y i n g t h e c h a r a c t e r s t i c s eq . i s : ) ;
disp ( float ( l ) ) ;
65
// c a p t i o n :
determine characterstics eq and steady state error
2
3
4
// e x a m p l e 6 . 1 0 . 1 1
// p a g e 181
// J=moment o f i n e r t i a , f=C , K= c o n t r o l l e r g a i n ,Wn=
n a t u r a l f r e q u e n c y , z e t a=damping r a t i o
syms f J K Kt
s = %s ;
A = sym ((1/( J * s ^2+ f * s ) ) ) ;
J =250;
K =8*10^4;
B = eval ( A )
a =( K * B ) ;
H1 = s * Kt ;
b =(1+ a * H1 ) ;
b = simple ( b ) ;
CL1 = a / b ;
CL1 = simple ( CL1 ) ;
H =1;
c =1+ CL1 * H ;
c = simple ( c ) ;
CL = CL1 / c
CL = simple ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
66
Wn = sqrt (80000/250) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=(80000 Kt+f ) / 2 5 0
zeta =1; // f o r c r i t i c a l damping
d =2* zeta * Wn ;
v =[320 d 1];
CH = poly (v , s , c o e f f ) ;
r = float (5*2* %pi /60) ;
// s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2
z e t a /Wn)
31 Ess =(2* zeta / Wn ) * r ;
32 disp ( Ess , s t e a d y s t a t e e r r o r = ) ;
23
24
25
26
27
28
29
30
Scilab code Exa 6.10.12 determine WnWd zeta and steady state error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// c a p t i o n : determine Wn ,Wd,
zeta and steady state error
// e x a m p l e 6 . 1 0 . 1 2
// p a g e 182
clc ;
s = %s ;
G = sym ( 2 5 / ( s ( s +5) ) ) ;
G = simple ( G ) ;
H =1;
CL = G /. H ;
CL = simple ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
printf ( t h e c h a r . eq i s : )
disp ( s 2+5 s +25 )
Wn = sqrt (25) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=5
zeta =5/(2* Wn ) ; // damping r a t i o
d = zeta * Wn ; // d a m p i n g f a c t o r
z = sqrt (1 - zeta ^2) ;
Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n
Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t
67
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2
z e t a /Wn)
Ess =(2* zeta / Wn ) ; // s t e a d y s t a t e e r r o r
disp ( p a r t ( a ) : )
disp ( Wn , n a t u r a l f r e q u e n c y ,Wn= ) ;
disp ( zeta , damping r a t i o , z e t a= ) ;
disp ( Wd , d a m p e d f r e q u e n c y o f o s c i l l a t i o n ,Wd= ) ;
disp ( Mp , % max . p e a k o v e r s h o o t , Mp= ) ;
disp ( Ess , s t e a d y s t a t e e r r o r , E s s= ) ;
// i f damping r a t i o i s i n c r e a s e d from 0 . 5 t o 0 . 7 5 by
i n c o r p o r a t i n g tachometer feedback
zeta =0.75;
H1 = sym ( s Kt ) // t a c h o m e t e r f e e d b a c k
CL1 = G /(1+ G * H1 ) ;
CL1 = simple ( CL1 ) ;
CL2 = CL1 /(1+ H * CL1 ) ;
CL2 = simple ( CL2 ) ;
disp ( CL2 , C( s ) /R( s )= ) ;
Wn = sqrt (25) ;
// 2 z e t a Wn=25Kt +5;
Kt =(2* zeta * Wn -5) /25; // t a c h o m e t e r g a i n
Mp1 = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; //
% peak overshoot
disp ( A f t e r a p p l y i n g t a c h o m e t e r f e e d b a c k : )
disp ( Kt , t a c h o m e t e r g a i n , Kt= ) ;
disp ( Mp1 , % p e a k o v e r s h o o t , Mp1= ) ;
68
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
G = sym ( K/ ( s ( s +6) ) ) ;
H =0.2;
CL = G /(1+ G * H ) ;
CL = simple ( CL ) ;
Wn = sqrt ( K /5)
zeta =0.7 // ( g i v e n ) damping r a t i o
// 2 z e t a Wn=6
Wn =6/(2* zeta ) ;
K = Wn ^2*5;
ts =4/( zeta * Wn ) ; // s e t t l i n g t i m e
Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; //
% peak overshoot
tp = %pi /( Wn * sqrt (1 - zeta ^2) ) ; // p e a k t i m e
disp ( Wn , n a t u r a l f r e q u e n c y ,Wn= ) ;
disp ( Mp , % max . p e a k o v e r s h o o t , Mp= ) ;
disp ( ts , s e t t l i n g t i m e , t s= ) ;
disp ( tp , p e a k t i m e , t p= ) ;
Scilab code Exa 6.10.14 determine Mp Ess and steady state value
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// c a p t i o n : determine Mp , E s s a n d s t e a d y s t a t e v a l u e
// e x a m p l e 6 . 1 0 . 1 4
// p a g e 185
// t h e r e a r e two i n p u t s : R( s ) i s r e f e r e n c e i n p u t and
Tl ( s ) i s l o a d t o r q u e
clc ;
s = %s ;
A = sym ( 1 / ( 0 . 1 5 s 2 + 0 . 9 s ) ) ;
K =6;
// w h i l e c o n s i d e r i n g R( s ) , we t a k e Tl ( s ) =0
G =( A * K ) ; // i n s e r i e s
H =1;
CL = G /(1+ G * H ) ;
CL = simple ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
69
15 Wn = sqrt (40) ; // n a t u r a l f r e q u e n c y
16 // 2 z e t a Wn=6
17 zeta =6/(2* Wn ) ; // damping r a t i o
18 Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; //
19
20
21
22
23
24
25
26
27
28
29
30
31
% peak overshoot
// s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2
z e t a /Wn)
Ess =(2* zeta / Wn ) ; // s t e a d y s t a t e e r r o r
disp ( Mp , % p e a k o v e r s h o o t= ) ;
disp ( Ess , s t e a d y s t a t e e r r o r= ) ;
printf ( Now c o n s i d e r i n g e f f e c t o f Tl ( s ) , put R( s ) =0\n
);
H =6;
CL1 = A /(1+ A * H ) ;
CL1 = simple ( CL1 ) ;
disp ( CL1 , C( s ) /Tl ( s )= ) ; //ve s i g n i n d i c a t e s o u t p u t
p o s i t i o n l a g s behind the input
Tl =1/ s ; // g i v e n
C = - Tl * CL1 ;
Css = limit ( s *C ,s ,0) ;
disp ( Css , s t e a d y s t a t e v a l u e o f o u t p u t= ) ;
// c a p t i o n : determine Wn , z e t a a n d M p
// e x a m p l e 6 . 1 0 . 1 6
// p a g e 187
s = %s ;
num =1;
den = sym ( s ( 1 + 0 . 5 s ) ( 1 + 0 . 2 s ) ) ;
c = num / den ;
c = simple ( c ) ;
disp (c , C( s ) /E( s )= ) ;
G=c;
H =1;
70
12
13
14
15
16
17
18
19
20
21
22
CL = G /(1+ G * H ) ;
CL = simple ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
A = pfss ((10/( s ^3+7* s ^2+10* s +10) ) ) ;
d = denom ( A (1) ) ;
b = coeff ( denom ( A (1) ) )
printf ( f o r o s c i l l a t o r y r o o t s : )
Wn = sqrt ( b (1 ,1) ) ; // n a t u r a l f r e q u e n c y
// 2 z e t a Wn= 1 . 5 ;
zeta =1.5/(2* Wn ) ; // damping r a t i o
Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; //
% peak overshoot
23 disp ( Wn , n a t u r a l f r e q u e n c y= ) ;
24 disp ( zeta , damping r a t i o = ) ;
25 disp ( Mp , % p e a k o v e r s h o o t= ) ;
// c a p t i o n : d e t e r m i n e K p K v K a
// e x a m p l e 6 . 1 0 . 1 7
// p a g e 188
s = %s ;
syms t ;
num = sym ( 2 ( s 2+3 s +20) ) ;
den = sym ( s ( s +2) ( s 2+4 s +10) ) ;
GH = num / den ;
GH = simple ( GH ) ;
disp ( GH , G( s )H( s )= ) ;
input1 =5;
Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r
coefficient
Ess =5*(1/(1+ Kp ) ) ; // s t e a d y s t a t e e r r o r
e =(1/( %inf +1) ) ;
e =0;
Ess = e ;
71
17 disp ( Kp , s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t = ) ;
18 disp ( Ess , s t e a d y s t a t e e r r o r= ) ;
19 input2 =4* t ;
20 Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r
21
22
23
24
25
26
27
28
29
coefficient
Ess =(1/ Kv ) *4; // s t e a d y s t a t e e r r o r
disp ( Kv , s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t = ) ;
disp ( Ess , s t e a d y s t a t e e r r o r= ) ;
input3 =(4* t ^2) /2;
Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
coefficient
Ess =(1/ Ka ) *4; // s t e a d y s t a t e e r r o r
disp ( Ka , s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t = ) ;
disp ( s t e a d y s t a t e e r r o r= ) ;
disp ( i n f i n i t y )
// c a p t i o n : d e t e r m i n e K p K v K a
// e x a m p l e 6 . 1 0 . 1 7
// p a g e 188
s = %s ;
syms t K zeta Wn ;
num = K ;
den = sym ( s ( s 2+2 z e t a Wn s+Wn 2 ) ) ;
G = num / den ;
G = simple ( G ) ;
disp (G , G( s )= ) ;
Kp = limit (G ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r
coefficient
disp ( Kp , s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t , Kp= ) ;
Kv = limit ( s *G ,s ,0) ; // s t a t i c v e l o c i t y e r r o r
coefficient
disp ( Kv , s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t , Kv= ) ;
Ka = limit ( s ^2* G ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
72
16
17
18
19
20
21
22
23
24
25
26
27
28
coefficient
disp ( Ka , s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t , Ka= )
;
printf ( f o r ( i i ) : ) ;
num = sym ( 1 0 0 ( s +2) ( s +40) ) ;
den = sym ( s 3 ( s 2+4 s +200) ) ;
GH = num / den ;
GH = simple ( GH ) ;
disp ( GH , G( s )H( s )= ) ;
Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r
coefficient
disp ( Kp , s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t , Kp= ) ;
Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r
coefficient
disp ( Kv , s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t , Kv= ) ;
Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
coefficient
disp ( Ka , s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t , Ka= )
;
// c a p t i o n : d e t e r m i n e s t e a d y s t a t e e r r o r
// e x a m p l e 6 . 1 0 . 1 9
// p a g e 189
s = %s ;
syms K bta alpha G
num = sym ( K s+b t a ) ;
den = sym ( s 2+ a l p h a s+b t a ) ;
CL = num / den ;
disp ( CL , C( s ) /R( s )= ) ; //(1)
H =1;
// a l s o
cl = G /(1+ G * H ) ;
disp ( cl , a l s o , C( s ) /R( s )= ) ; //(2)
73
14
15
16
17
18
19
20
21
22
23
24
// from eq . ( 1 ) and ( 2 ) , we g e t
G = num /( s ^2+ s *( alpha - K ) ) ;
disp (G , G( s )= ) ;
B =1/(1+ G ) ;
B = simple ( B ) ;
disp (B , E( s ) /R( s )= ) ;
R =1/ s ^2;
E=B*R;
E = simple ( E ) ;
Ess = limit ( s *E ,s ,0) ;
disp ( Ess , s t e a d y s t a t e e r r o r= ) ;
Scilab code Exa 6.10.20 determine steady state error and error coefficient
1
// c a p t i o n :
determine steady state error and error coefficient
2 // e x a m p l e 6 . 1 0 . 2 0
3 // p a g e 189
4 s = %s ;
5 syms t a0 a1 a2 ;
6 r = a0 + a1 * t +( a2 /2) * t ^2;
7 // s i n c e f o r r o n l y u p t o 2 nd o r d e r
8
9
10
11
12
13
14
15
16
17
18
derivative is
non z e r o , s o o n l y c o e f f . C0 C1 C2 e x i s t
num =20;
den = sym ( ( s ( s +2) ) ) ;
G = num / den ;
disp (G , G( s )= ) ;
A =1/(1+ G ) ;
A = simple ( A ) ;
disp (A , E( s ) /R( s )= ) ;
C0 = limit (A ,s ,0) ;
B = sym ( ( ( 2 0 ) / ( s 2+2 s +20) ) ) ; // on s i m p l y f y i n g A=1B
d = diff ( -B , s ) ;
C1 = limit (d ,s ,0) ;
74
19
20
21
22
23
24
25
26
27
d1 = diff ( -B ,s ,2) ;
C2 = limit ( d1 ,s ,0) ;
r1 = diff (r , t ) ;
r2 = diff (r ,t ,2) ;
e =( C0 * r ) +( C1 * r1 ) +( C2 * r2 ) /2;
disp ( C0 , C0= ) ;
disp ( float ( C1 ) ,C1= ) ;
disp ( float ( C2 ) ,C2= ) ;
disp ( float ( e ) , s t e a d y s t a t e e r r o r , e= ) ;
Scilab code Exa 6.10.21 determine steady state error and error coefficient
1
// c a p t i o n :
determine steady state error and error coefficient
2 // e x a m p l e 6 . 1 0 . 2 1
3 // p a g e 191
4 s = %s ;
5 syms t ;
6 r =2+3* t +2* t ^3;
7 // s i n c e f o r r o n l y u p t o 2 nd o r d e r
8
9
10
11
12
13
14
15
16
17
18
19
20
derivative is
non z e r o , s o o n l y c o e f f . C0 C1 C2 e x i s t
G = sym ( 1 / ( s ( s +2) ) ) ;
A =1/(1+ G ) ;
A = simple ( A ) ;
disp (A , E( s ) /R( s )= ) ;
C0 = limit (A ,s ,0) ;
B = sym ( ( ( 1 ) / ( s 2+2 s +1) ) ) ; // on s i m p l y f y i n g A=1B
d = diff ( -B , s ) ;
C1 = limit (d ,s ,0) ;
d1 = diff ( -B ,s ,2) ;
C2 = limit ( d1 ,s ,0) ;
r1 = diff (r , t ) ;
r2 = diff (r ,t ,2) ;
d2 = diff ( -B ,s ,3)
75
21 C3 = limit ( d2 ,s ,0)
22 e =( C0 * r ) +( C1 * r1 ) +( C2 * r2 ) /2;
23 disp ( float ( e ) , s t e a d y s t a t e e r r o r , e= ) ;
24 disp ( C0 , C0= ) ;
25 disp ( float ( C1 ) ,C1= ) ;
26 disp ( float ( C2 ) ,C2= ) ;
27 disp ( float ( C3 ) ,C3= )
// c a p t i o n : d e t e r m i n e r e f e r e n c e v o l t a g e ,
Er and %change in terminal voltage
// e x a m p l e 6 . 1 0 . 2 2
// p a g e 191
clc ;
syms G H
s = %s ;
A = G /. H ;
disp (A , E0/ Er= ) ;
G =200; // g a i n
H =0.1;
B = eval ( A ) ;
disp (B , E0/ Er= ) ;
E0 =250;
Er =(1/ B ) * E0 ;
disp ( f o r c l o s e d l o o p s y s t e m : ) ;
disp ( float ( Er ) , r e f e r e n c e v o l t a g e , Er= ) ;
disp ( f o r o p e n l o o p s y s t e m : ) ;
disp ( float ( E0 / G ) , Er=E0/G= ) ;
disp ( p a r t ( b ) )
disp ( f o r c l o s e d l o o p s y s t e m : )
disp ( a s t h e f o r w a r d p a t h g a i n i s r e d u c e d by 10%,
t h e new v a l u e o f g a i n ,G i s 180 )
76
G =180 // g a i n
pcG =10 // p e r c e n t a g e c h a n g e i n G
S =1/(1+ G * H )
disp (S , s e n s i t i v i t y , S= ) ;
disp ( s i n c e S =1/19 ,
( given ) )
pcM = S * pcG // p e r c e n t a g e c h a n g e i n o v e r a l l g a i n ,M
pcEo = pcM
disp ( pcM , p e r c e n t a g e c h a n g e i n o v e r a l l g a i n ,M= )
disp ( pcEo , p e r c e n t a g e c h a n g e i n t e r m i n a l v o l t a g e , Eo=
)
32 disp ( f o r open l o o p s y s t e m : )
33 pcEo =(25/250) *100
34 disp ( pcEo , p e r c e n t a g e c h a n g e i n t e r m i n a l v o l t a g e , Eo=
)
23
24
25
26
27
28
29
30
31
// c a p t i o n : d e t e r m i n e s e n s i t i v i t y w . r . t K a n d H
// e x a m p l e 6 . 1 0 . 2 3
// p a g e 192
syms Wn zeta K H ;
s = %s ;
A = sym ( Wn 2 / ( s 2+2 z e t a Wn s ) ) ;
B =( A * K ) ;
CL = B /(1+ B * H ) ;
CL = simple ( CL ) ;
disp ( CL , o v e r a l l t r a n s f e r f u n c t i o n :M( s )= ) ;
disp ( s e n s i t i v i t y w . r . t K : ) ;
a = diff ( CL , K ) ;
b = K / CL ;
b = simple ( b ) ;
Sk = a * b ;
Sk = simple ( Sk ) ;
disp ( Sk , s e n s i t i v i t y w . r . t K , Sk= ) ;
disp ( s e n s i t i v i t y w . r . t H : ) ;
77
19
20
21
22
23
24
c = diff ( CL , H ) ;
d = H / CL ;
d = simple ( d ) ;
Sh = c * d ;
Sh = simple ( Sh ) ;
disp ( Sh , s e n s i t i v i t y w . r . t H , Sh= ) ;
78
Chapter 7
STABILITY ANALYSIS OF
CONTROL SYSTEMS
// c a p t i o n : r o o t l o c u s
// e x a m p l e 2
79
80
81
// c a p t i o n : r o o t l o c u s
// e x a m p l e 3
// p a g e 292
82
4 s = %s ;
5 g =1/( s *( s +1) *( s +3) ) ;
6 G = syslin ( c ,g )
7 evans (g ,200)
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 7 . 5 . 1
// p a g e 202
clc ;
s = %s ;
A = s ^3+4.5* s ^2+3.5* s +1.5;
b = coeff ( A )
n = length ( b )
B = routh_t ( A )
disp (B , r o u t h t a b l e : ) ;
c =0;
for ( i =1: n )
if ( B (i ,1) <0)
c = c +1;
end
end
if (c >=1)
disp ( s y s t e m i s u n s t a b l e )
else ( s y s t e m i s s t a b l e )
end
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 7 . 5 . 2
// p a g e 202
83
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
s = %s ;
A = s ^3+4*10^2* s ^2+5*10^4* s +2*10^6;
b = coeff ( A )
n = length ( b )
B = routh_t ( A )
disp (B , r o u t h t a b l e : ) ;
c =0;
for ( i =1: n )
if ( B (i ,1) <0)
c = c +1;
end
end
if (c >=1)
printf ( \n s y s t e m i s u n s t a b l e )
else ( s y s t e m i s s t a b l e )
end
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 7 . 5 . 3
// p a g e 203
s = %s ;
A = s ^5+4*1.5* s ^4+4* s ^3+4* s ^2+5* s +10;
C =2* s +5;
CL = A / C ;
disp ( CL , C( s ) /R( s )= ) ;
disp ( =0 ,A , c h a r a c t e r i s t i c s eq i s : )
b = coeff ( A )
n = length ( b )
B = routh_t ( A )
disp (B , r o u t h t a b l e : ) ;
c =0;
r =1;
for ( i =1: n )
84
17
if ( B (i ,1) <0)
18
c = c +1;
19
if ( i == n & B (n ,1) <0)
20
r=r;
21
else
22
r = r +1;
23
end
24
end
25 end
26 if (c >=1)
27
printf ( s y s t e m i s u n s t a b l e \n ) ;
28 else ( s y s t e m i s s t a b l e ) ;
29 end
30 mprintf ( no . o f r o o t s w i t h p o s i t i v e
r e a l p a r t s=%d ,r
);
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 7 . 5 . 4
// p a g e 203
ieee (2)
s = %s ;
A = s ^5+ s ^4+2* s ^3+2* s ^2+11* s +10;
b = coeff ( A ) ;
n = length ( b ) ;
B = routh_t ( A ) ;
K=B;
c =0;
syms eps ;
x = limit ( eps , eps ,0) ;
y = limit ((( -1+2* eps ) / eps ) ,eps ,0) ;
z = limit ((( -1+2* eps -10* eps ^2) /( -1+2* eps ) ) ,eps ,0) ;
// a f t e r p u t t i n g t h e l i m i t we g e t :
K (3 ,1) =0;
85
18 K (4 ,1) = - %inf ;
19 K (5 ,1) =1;
20 disp (K , r o u t h t a b l e : )
21 printf ( There a r e two s i g n c h a n g e s o f
f i r s t column ,
h e n c e t h e s y s t e m i s u n s t a b l e \n )
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 7 . 5 . 5
// p a g e 204
s = %s ;
A = s ^6+ s ^5+5* s ^4+3* s ^3+2* s ^2 -4* s -8;
b = coeff ( A )
n = length ( b )
routh =[ b ([7 ,5 ,3 ,1]) ; b ([6 ,4 ,2]) ,0];
c =[ routh (1 ,1) , routh (1 ,3) ; routh (2 ,1) , routh (2 ,3) ]
d =[ routh (1 ,1) , routh (1 ,4) ; routh (2 ,1) , routh (2 ,4) ]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,- det ( c )
/ routh (2 ,1) ,- det ( d ) / routh (2 ,1) ,0];
routh1 = routh ;
e =[ routh (2 ,1) , routh (2 ,2) ; routh (3 ,1) , routh (3 ,2) ]
f =[ routh (2 ,1) , routh (2 ,3) ; routh (3 ,1) , routh (3 ,3) ]
routh =[ routh ; - det ( e ) / routh (3 ,1) ,- det ( f ) / routh (3 ,1)
,0 ,0];
disp ( s i n c e a l l e l e m e n t s o f f o u r t h row a r e z e r o , s o
we make a u x i l i a r y e q u a t i o n )
A = sym ( 2 s 4+6 s 28 )
B = diff (A , s )
routh =[ routh1 ;8 ,12 ,0 ,0]
g =[ routh (3 ,1) , routh (3 ,3) ; routh (4 ,1) , routh (4 ,3) ]
routh =[ routh ; - det ( routh (3:4 ,1:2) ) / routh (4 ,1) ,- det ( g )
/ routh (4 ,1) ,0 ,0];
routh =[ routh ; - det ( routh (4:5 ,1:2) ) / routh (5 ,1) ,0 ,0 ,0];
86
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 7 . 5 . 6
// p a g e 206
s = %s ;
syms T
num = exp ( - s * T ) ;
den = s *( s +2) ;
G = num / den ;
H =1;
a =(1+ G * H ) ;
CL = G / a ;
CL = simple ( CL ) ;
87
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
CH = s ^2+2* s + exp ( - s * T ) ;
// exp ( s T)=1sT+(sT ) 2 / 2 + . . . .
CH = s ^2+(2 - T ) * s +1;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
b =[ c0 c1 c2 ]
n =3;
routh =[ b ([3 ,1]) ; b ([2]) ,0];
routh =[ routh ; simple ( - det ( routh ) / routh (2 ,1) ) ,0]
disp ( routh , r o u t h= ) ;
disp ( f o r g i v e n s y s t e m t o be s t a b l e : ) ;
disp ( 2T>0 ) ;
disp ( which g i v e s : ) ;
disp ( T<2 ) ;
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 7 . 5 . 7 . ( a )
// p a g e 207
s = %s ;
syms T K
P = s *( s *( s +10) + T ) ;
CH = sym ( s 3+10 s 2+T s+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
88
// c a p t i o n : v a l u e o f K o f c h a r a c t e r s t i c s e q
// e x a m p l e 7 . 5 . 7 . ( b )
// p a g e 207
s = %s ;
syms K s1 ;
CH = s ^3+10* s ^2+18* s + K
s = s1 -1;
CH = eval ( CH ) ;
CH = simple ( CH ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= ) ;
c0 = coeffs ( CH , s 1 ,0) ;
c1 = coeffs ( CH , s 1 ,1) ;
c2 = coeffs ( CH , s 1 ,2) ;
c3 = coeffs ( CH , s 1 ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be s t a b l e : ) ;
disp ( (( (K16) ) / 7 ) >0 and K9>0 ) ;
disp ( which g i v e s : ) ;
disp ( 9<K<16 ) ;
89
// c a p t i o n : v a l u e o f K i n t e r m s o f T 1 a n d T 2
// e x a m p l e 7 . 5 . 8
// p a g e 207
s = %s ;
syms K T1 T2 ;
m = s *( s * T1 +1) *( s * T2 +1)
G=K/m;
CH =1+ G ;
disp ( on s i m p l y f y i n g CH )
CH = m + K ;
CH = simple ( CH ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= ) ;
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be s t a b l e : ) ;
disp ( K>0 and ( (KT1T2T2T1 ) / ( T2+T1 ) ) >0 ) ;
disp ( which g i v e s : ) ;
disp ( 0<K<((1/ T1 ) +(1/T2 ) ) ) ;
90
91
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 7 . 1 7 . 1
// p a g e 236
clf ;
s = %s ;
s1 = - s ;
g =50/(( s +1) *( s +2) ) ;
g1 =50/(( s1 +1) *( s1 +2) ) ;
GH = syslin ( c ,g )
GH1 = syslin ( c , g1 )
nyquist ( GH ) ;
nyquist ( GH1 ) ;
mtlb_axis ([ -5 30 -20 20]) ;
xtitle ( N y q u i s t p l o t o f 5 0 / ( ( s +1) ( s +2) ) )
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s n o t e n c i r c l e d by
N y q u i s t p l o t , s o N=0 and P=0( g i v e n ) )
N =0; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s ) p l o t
P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s s t a b l e . )
93
94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 7 . 1 7 . 2
// p a g e 237
clf () ;
s = %s ;
s1 = - s ;
disp ( f o r K=1.25 )
g =(1.25*( s +1) ) /(( s +0.5) *( s -2) ) ;
g1 =(1.25*( s1 +1) ) /(( s1 +0.5) *( s1 -2) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
mtlb_axis ([ -1.5 0.2 -0.3 0.3]) ;
xtitle ( N y q u i s t p l o t o f ( 1 0 ( s 1) ) / ( ( s +2) ( s +3) ) ; )
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s
encircled
c l o c k w i s e by N y q u i s t p l o t , s o N=1 and P=1( g i v e n )
)
N = -1; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s )
plot anticlockwise
P =1; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=2 , t h e r e a r e two r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s u n s t a b l e . )
95
96
97
16
17
18
19
20
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 7 . 1 7 . 2 i i
// p a g e 237
disp ( f o r K=2.5 )
g =(2.5*( s +1) ) /(( s +0.5) *( s -2) ) ;
g1 =(2.5*( s1 +1) ) /(( s1 +0.5) *( s1 -2) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
mtlb_axis ([ -3 0.5 -0.6 0.6]) ;
xtitle ( N y q u i s t p l o t o f ( 2 . 5 ( s +1) ) / ( ( s + 0 . 5 ) ( s 2) )
)
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s
encircled
a n t i c l o c k w i s e by N y q u i s t p l o t , s o N=1 and P=1(
given ) )
N =1; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s ) p l o t
anticlockwise
P =1; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s s t a b l e . )
98
99
100
18
19
20
21
22
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 7 . 1 7 . 3
// p a g e 238
clf () ;
s = %s ;
s1 = - s ;
g =( s +0.25) /( s ^2*( s +0.5) *( s +1) ) ;
g1 =( s1 +0.25) /( s1 ^2*( s1 +0.5) *( s1 +1) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
mtlb_axis ([ -2000 500 -30 30]) ;
xtitle ( N y q u i s t p l o t o f ( s + 0 . 2 5 ) / ( s 2 ( s + 0 . 5 ) ( s +1) )
)
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s
encircled
c l o c k w i s e by N y q u i s t p l o t , s o N=1 and P=1( g i v e n )
)
N = -1; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s )
plot anticlockwise
P =1; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=2 , t h e r e a r e two r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s u n s t a b l e . )
101
102
103
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 7 . 1 7 . 7
// p a g e 244
clf () ;
s = %s ;
s1 = - s ;
g =(2.2/( s *( s +1) *( s ^2+2* s +2) ) )
104
105
1+%i 0 , s o s y s t e m i s m a r g i n a l l y s t a b l e and
output r e p r e s e n t s s u s t a i n e d o s c i l l a t i o n s . )
// c a p t i o n : g a i n m a r g i n a n d p h a s e m a r g i n
// e x a m p l e 7 . 1 7 . 9
// p a g e 245
s = %s ;
syms w ;
s1 = - s ;
gh =(32/( s *( s + sqrt (6) ) ^3) ) ;
g = sym ((32/( s *( s + sqrt (6) ) ^3) ) ) ;
s = %i * w ;
a = eval ( g ) ;
w = sqrt (2) ;
b = float ( eval ( abs ( a ) ) ) ;
disp (b , a t w=s q r t ( 2 ) , |G( jw )H( jw ) |= ) ;
GH = syslin ( c , gh ) ;
gm = g_margin ( GH ) ;
pm = p_margin ( GH ) ;
disp ( gm , Gain m a r g i n= ) ;
disp ( pm , Phase m a r g i n= ) ;
disp ( s i n c e gm=0 and pm=0 , s o s y s t e m i s m a r g i n a l l y
s t a b l e )
106
107
// c a p t i o n : s t a b i l i t y u s i n g b o d e p l o t
// e x a m p l e 7 . 1 9 . 1
// p a g e 280
s = %s ;
g =50/(( s +1) *( s +2) ) ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
gm = g_margin ( G )
108
109
so system i s s t a b l e )
// c a p t i o n : g a i n m a r g i n a n d p h a s e m a r g i n
// e x a m p l e 7 . 1 9 . 2
// p a g e 282
110
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
s = %s ;
g =((2*( s +0.25) ) /( s ^2*( s +1) *( s +0.5) ) ) ;
G = syslin ( c ,g )
fmin =0.1;
fmax =100;
bode (G , fmin , fmax )
[ gm , freqGM ]= g_margin ( G ) ;
[ pm , freqPM ]= p_margin ( G ) ;
show_margins ( G ) ;
disp ( gm , g a i n m a r g i n= ) ;
disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
disp ( pm , p h a s e m a r g i n= ) ;
disp (( freqPM *2* %pi ) , p h a s e m a r g i n f r e q= ) ;
show_margins ( G ) ;
disp ( s i n c e g a i n and p h a s e m a r g i n a r e b o t h n e g a t i v e
so system i s u n s t a b l e )
// c a p t i o n : s t a b i l i t y u s i n g b o d e p l o t
// e x a m p l e 7 . 1 9 . 3
// p a g e 283
s = %s ;
g =(48*( s +10) ) /( s *( s +20) *( s ^2+2.4* s +16) ) ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
gm = g_margin ( G )
pm = p_margin ( G )
disp ( gm , g a i n m a r g i n= ) ;
disp ( pm , p h a s e m a r g i n= ) ;
111
112
disp ( s i n c e g a i n and p h a s e m a r g i n a r e b o t h p o s i t i v e
so system i s s t a b l e )
113
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
G = K /( s *( s +4) ) ;
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +4) ) + K
CH = sym ( ( s ( s +4) )+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
eq =( s *( s +4) )
p = roots ( eq )
disp (p , open l o o p p o l e s a r e : )
K = sym ( ( s ( s +4) ) )
d = diff (K , s )
e =2* s +4
P =2;
Z =0;
disp ( s i n c e 2 l i e s on r o o t l o c u s s o breakaway p o i n t
i s 2 )
for ( k =0:1)
A =((2* k +1) *180) /( P - Z ) ;
disp (A , a s y m p t o t e a r e a t a n g l e : )
end
x =((0 -4) -0) /( P - Z ) // ( s u m o f P s u m o f Z ) / ( PZ )
disp (x , a s y m p t o t e s i n t e r s e c t a t )
disp ( s i n c e |G( s ) H( s ) |=1 )
disp ( which g i v e s K=8 )
k =8
g = k /( s *( s +4) )
G = syslin ( c ,g )
evans (g ,200)
xgrid (2)
// c a p t i o n : r o o t l o c u s d e s c r i p t i o n
// e x a m p l e 7 . 2 4 . 2
114
115
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// p a g e 296
s = %s ;
syms K ;
GH = K /( s *( s +1) *( s +3) )
zeta =0.5
// from g i v e n d a t a
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +1) *( s +3) ) + K
CH = sym ( ( s ( s +1) ( s +3) )+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0]
K = sym ( ( s 3+4 s 2+3 s ) )
d = diff (K , s )
e = -3* s ^2 -8* s -3
r1 = roots ( e )
disp ( r1 , r o o t s= )
disp ( 0.45 i s b r e a k away p o i n t s i n c e i t l i e s on
root l o c u s )
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( (12 K) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K=12 , f o r m a r g i a n l s t a b i l i t y ) ;
K =12;
k =12
a =4* s ^2+ k // i n t e r s e c t i o n o f r o o t l o c u s w i t h i m a g i n a r y
plane
r = roots ( a )
g = k /( s *( s +1) *( s +3) )
116
39 G = syslin ( c ,g )
40 evans (g ,8)
41 xgrid (2)
42 disp ( t h e l i n e t h e t a=a c o s ( z e t a ) =60 i n t e r s e c t s
43
44
45
46
47
48
49
50
51
root
l o c u s a t s a =( 0.35+ i 0 . 6 ) )
disp ( t h e v a l u e o f K a t s=s a i s f i n d t o be 1 . 6 6 )
disp ( t h e v a l u e o f K a t s=4 )
disp ( K=12 )
disp ( a t K=1.66 )
k =1.66
H =1
G = k /( s *( s +1) *( s +3) )
CL = G /(1+ G * H )
disp ( CL , C( s ) /R( s )= )
// c a p t i o n : r o o t l o c u s d e s c r i p t i o n
// e x a m p l e 7 . 2 4 . 3
// p a g e 299
clc ;
s = %s ;
syms K
G = K /( s *( s +6) *( s ^2+4* s +13) ) ;
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +6) *( s ^2+4* s +13) ) + K
CH = sym ( ( s ( s +6) ( s 2+4 s +13) )+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
eq =( s *( s +6) *( s ^2+4* s +13) )
p = roots ( eq )
disp (p , open l o o p p o l e s a r e : )
phi1 =180 -( atan (3/2) *180/ %pi )
phi2 = atan (3/4) *180/ %pi
117
118
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
phi3 =90
phi_p2 =180 -( phi1 + phi2 + phi3 )
phi_p3 = - phi_p2
disp ( phi_p2 , a n g l e o f d e p a r t u r e f o r 2+3 i = )
disp ( phi_p3 , a n g l e o f d e p a r t u r e f o r 23 i= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh
(1 ,3) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
routh =[ routh ;K ,0 ,0]
K = sym ( ( s ( s +6) ( s 2+4 s +13) ) )
d = diff (K , s )
e = -(4* s ^3+30* s ^2+74* s +78)
f=-e;
r = roots ( f ) ;
disp (r , r= )
disp ( s i n c e 4.2 l i e s on r o o t l o c u s , s o t h e
breakaway p o i n t i s 4.2 )
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( ( 7 8 0 . 3 4 K) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K= 2 2 9 . 4 ) ;
K =229.4;
k =229.4;
a =29.2* s ^2+229.4 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s
plane
r1 = roots ( a )
g = k /( s *( s +6) *( s ^2+4* s +13) ) ;
119
i n te r s e ct i o n of root locus
w i t h i m a g i n a r y a x i s = )
// c a p t i o n : r o o t l o c u s
// e x a m p l e 7 . 2 4 . 4
// p a g e 301
120
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
clc ;
s = %s ;
syms K ;
GH = K /( s *( s +4) *( s ^2+4* s +13) )
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +4) *( s ^2+4* s +13) ) + K
CH = sym ( ( s ( s +4) ( s 2+4 s +13) )+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh
(1 ,3) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
routh =[ routh ;K ,0 ,0]
K = sym ( ( s ( s +4) ( s 2+4 s +13) ) )
d = diff (K , s )
e =( -4* s ^3+24* s ^2+58* s +52)
r = roots ( e )
disp ( s i n c e 2 l i e s on r o o t l o c u s s o c o m p l e x
breakaway p o i n t i s 2+ i 1 . 5 8 and 2 i 1 . 5 8 )
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( ((20 4K) / 5 ) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K=5 ) ;
K =5;
k =5
a =5* s ^2+5 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s p l a n e
r = roots ( a )
g = k /( s *( s +2) *( s ^2+2* s +2) )
121
40 G = syslin ( c ,g )
41 evans (g ,200)
42 xgrid (2)
43 eq =( s *( s +4) *( s ^2+4* s +13) )
44 p = roots ( eq )
45 disp (p , open l o o p p o l e s a r e : )
46 phi1 =180 -( atan (3/2) *180/ %pi )
47 phi2 = atan (3/2) *180/ %pi
48 phi3 =90
49 phi_p2 =180 -( phi1 + phi2 + phi3 )
50 phi_p3 = - phi_p2
51 disp ( phi_p2 , a n g l e o f d e p a r t u r e
52 disp ( phi_p3 , a n g l e o f d e p a r t u r e
f o r 2+3 i = )
f o r 23 i= )
// c a p t i o n : r o o t l o c u s
// e x a m p l e 7 . 2 4 . 6
// p a g e 304
clc ;
s = %s ;
syms K ;
clf () ;
g =( K *( s +1) /( s ^2+0.4* s +0.4) ) ;
eq =( s ^2+0.4* s +0.4)
p = roots ( eq )
disp (p , open l o o p p o l e s a r e : ) ;
P =2;
Z =1;
k =0
A =((2* k +1) *180) /( P - Z ) ;
disp (A , a s y m p t o t e a r e a t a n g l e : )
CH =( s ^2+0.4* s +0.4) + K *( s +1)
122
123
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2) )
8 zeta =0.3
9 // from g i v e n d a t a
124
125
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +2) *( s +4) ) + K
K = sym ( ( s 3+6 s 2+8 s ) )
d = diff (K , s )
e = -3* s ^2 -12* s -8
r1 = roots ( e )
disp ( r1 , r o o t s= )
disp ( 0.842 i s b r e a k away p o i n t s i n c i t l i e s on
root l o c u s )
CH = sym ( s 3+6 s 2+8 s+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( (48 K) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K=48 ) ;
K =48;
k =48
a =6* s ^2+48 // i n t e r s e c t i o n o f r o o t l o c u s w i t h
imaginary plane
r = roots ( a )
g = k /( s *( s +2) *( s +4) )
G = syslin ( c ,g )
evans (g ,8)
xgrid (2)
disp ( t h e l i n e t h e t a=a c o s ( z e t a ) =72.5 i n t e r s e c t s r o o t
l o c u s a t s a =(0.5+ i 1 . 6 5 ) )
disp ( t h e v a l u e o f K a t s=s a i s f i n d t o be 1 4 . 8 7 f o r
126
45
46
47
48
49
50
Mp=40% )
K =14.87
ts =4/0.5
// t s =4/( z e t a wn )
Kv = limit ( s * GH ,s ,0)
Kv = eval ( Kv )
Kv = float ( Kv )
disp ( Kv , Kv= ) ;
// c a p t i o n : r o o t l o c u s
127
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// e x a m p l e 7 . 2 4 . 8
// p a g e 308
clc ;
s = %s ;
syms K ;
GH = K /( s *( s +1) *( s +3) )
zeta =0.5
// from g i v e n d a t a
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +1) *( s +3) ) + K
CH = sym ( ( s ( s +1) ( s +3) )+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0]
K = sym ( ( s 3+4 s 2+3 s ) )
d = diff (K , s )
e = -3* s ^2 -8* s -3
r1 = roots ( e )
disp ( r1 , r o o t s= )
disp ( 0.45 i s b r e a k away p o i n t s i n c e i t l i e s on
root l o c u s )
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( (12 K) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K=12 , f o r m a r g i a n l s t a b i l i t y ) ;
K =12;
k =12
a =4* s ^2+ k // i n t e r s e c t i o n o f r o o t l o c u s w i t h i m a g i n a r y
plane
128
38 r = roots ( a )
39 disp (r , i n t e r s e c t i o n
40
41
42
43
44
45
46
47
48
49
50
51
// c a p t i o n : r o o t l o c u s
// e x a m p l e 7 . 2 4 . 9
// p a g e 308
clc ;
s = %s ;
syms K
clf () ;
g =( K *( s ^2+4) /( s *( s +1) ) ) ;
Z =2
P =2
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +1) ) + K *( s ^2+4)
CH = sym ( ( s ( s +1) )+K ( s 2+4) ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
129
130
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
eq =( s *( s +1) )
p = roots ( eq )
disp (p , open l o o p p o l e s a r e : )
K = sym ( ( s ( s +1) ) / ( s 2+4) )
d = diff (K , s )
e =2* s ^2 -8* s -8
r = roots ( e ) ;
disp (r , r= )
disp ( s i n c e 0.82 l i e s on r o o t l o c u s , s o t h e
breakaway p o i n t i s 0.82 )
disp ( by p u t t i n g s = 0.82 i n
|G( s ) H( s ) | = 1 , t h e
v a l u e o f K a t s = 0.82 i s K=0.2 )
k =0.2
g =( k *( s ^2+4) /( s *( s +1) ) ) ;
G = syslin ( c ,g )
evans (g ,200)
xgrid (2)
disp ( p a r t ( b ) )
disp ( by p u t t i n g s =0.69+ i 0 . 9 i n
=0.464 )
|G( s ) H( s ) | = 1 , K
Scilab code Exa 7.24.10 Overall Transfer Function and Root Locus
// C a p t i o n : o v e r a l l t r a n s f e r f u n c t i o n a n d r o o t l o c u s
// e x a m p l e 7 . 2 4 . 1 0
// p a g e 314
syms Ka Ke Kf Rf Lf eq N1 N2 N3 N4 N5
// where Ka= a m p l i f i e r g a i n ; Ke= e r r o r d e t e c t o r g a i n ;
Kf=m o t o r t o r q u e c o n s t ; Rf= f i e l d r e s i s t a n c e ; L f=
f i e l d i n d u c t a n c e Jeq=m o m e n t o f i n e r t i a ; f e q=
coeff of viscous friction ;
6 s = %s ;
1
2
3
4
5
131
132
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
d = N1 / N2 ;
e = N4 / N3 ;
f = N4 / N5 ;
n = N3 / N5
Ke =0.05; Kf =2; Rf =10; Lf =2; Jeq =0.5*10^ -4; feq
=10^ -4; d =0.1; e =5; f =0.5; n =0.2;
a =(1* Ke ) ; // i n s e r i e s
b = Kf /( Rf + s * Lf ) ;
c =1/( s *( Jeq * s + feq ) ) ;
g= (b*c)
// i n s e r i e s
h= (g*a)
// i n s e r i e s
j = ( h *0.02) // i n s e r i e s
k = j /(1+ j *0.5) ;
a1 =1/20;
cl = a1 * k
disp ( cl , C( s ) /R( s )= ) ;
clf () ;
G = syslin ( c , cl )
evans (G ,200)
xgrid (2)
// c a p t i o n : r o o t l o c u s
// e x a m p l e 7 . 2 4 . 1 1
// p a g e 308
clc ;
s = %s ;
syms K
clf () ;
g = K *( s +0.1) /( s *( s -0.2) *( s ^2+ s +0.6) ) ;
Z =2
P =2
133
134
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s -0.2) *( s ^2+ s +0.6) ) + K *( s +0.1)
CH = sym ( ( s ( s 0 . 2 ) ( s 2+ s + 0 . 6 ) )+K ( s + 0 . 1 ) ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
eq =( s *( s -0.2) *( s ^2+ s +0.6) )
p = roots ( eq )
disp (p , open l o o p p o l e s a r e : )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh
(1 ,3) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
routh =[ routh ;K ,0 ,0]
K = sym ( ( s ( s 0 . 2 ) ( s 2+ s + 0 . 6 ) ) / ( s + 0 . 1 ) )
d = diff (K , s )
e =3* s ^4+2* s ^3+0.64* s ^2+0.08* s -0.12
r = roots ( e ) ;
disp (r , r= )
disp ( s i n c e 0.37 and 0 . 0 8 l i e s on r o o t l o c u s , s o
t h e breakaway p o i n t i s 0.37 and 0 . 0 8 )
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( ( 6 2 5 K2 310K+33) / ( 6 2 5 K275)=0 ) ;
disp ( which g i v e s : ) ;
disp ( K= 0 . 1 4 8 and 0 . 3 5 2 ) ;
K1 =0.148;
K2 =0.352
a =((11 -25* K1 ) /20) * s ^2+ K1 /10 // i n t e r s e c t i o n o f r o o t
l o c u s w i t h jw a x i s
r1 = roots ( a )
135
of root
l o c u s w i t h jw a x i s
r2 = roots ( b )
disp ( r1 , r2 , r o o t l o c u s c r o s s e s i m a g i n a r y a x i s a t : )
g =( s +0.1) /( s *( s -0.2) *( s ^2+ s +0.6) ) ;
G = syslin ( c ,g )
evans (G ,200)
xgrid (2)
v =[ -1 0.7 -2 2];
mtlb_axis ( v )
136
Chapter 8
COMPENSATION OF
CONTROL SYSTEMS
// c a p t i o n : d e s i g n s u i t a b l e c o m p e n s a t o r
// e x a m p l e 8 . 6 . 1
// p a g e 339
s = %s ;
clf () ;
syms K ;
g =( K /( s *(1+0.2* s ) ) ) ;
Kv = limit ( s *g ,s ,0) ; // s t a t i c v e l o c i t y e r r o r
coefficient
// s i n c e Kv=10
K =10;
g =(10/( s *(1+0.2* s ) ) ) ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
xtitle ( u n c o m p e n s a t e d s y s t e m )
[ gm , freqGM ]= g_margin ( G ) ;
137
19 [ pm , freqPM ]= p_margin ( G ) ;
20 disp ( gm , g a i n m a r g i n= ) ;
21 disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
22 disp ( pm , p h a s e m a r g i n= ) ;
23 disp (( freqPM *2* %pi ) ,
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y = )
;
disp ( s i n c e P .M i s l e s s t h a n d e s i r e d v a l u e s o we
need phase l e a d network )
disp ( s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t
w=5.5 r a d / s e c and p o l e a t w=13.8 r a d / s e c and
applying gain to account a t t e n u a t i n f a c t o r . )
gc =(1+0.18* s ) /(1+0.072* s )
Gc = syslin ( c , gc )
disp ( Gc , t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r= ) ;
G1 = G * Gc
disp ( G1 , o v e r a l l t r a n s f e r f u n c t i o n= ) ;
fmin =0.01;
fmax =100;
figure () ;
bode ( G1 , fmin , fmax ) ;
show_margins ( G1 )
xtitle ( c o m p e n s a t e d s y s t e m )
[ gm , freqGM ]= g_margin ( G1 ) ;
[ pm , freqPM ]= p_margin ( G1 ) ;
disp ( pm , p h a s e m a r g i n o f c o m p e n s a t e d s y s t e m= ) ;
disp (( freqPM *2* %pi ) , g a i n c r o s s o v e r f r e q u e n c y = ) ;
// c a p t i o n : d e s i g n p h a s e l e a d c o m p e n s a t o r
138
139
140
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// e x a m p l e 8 . 6 . 2
// p a g e 340
clc ;
s = %s ;
clf () ;
syms K ;
g =( K /( s ^2*(1+0.05* s ) ) ) ;
Ka = limit ( s ^2* g ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
coefficient
// s i n c e Ka=100
K =100;
g =(100/( s ^2*(1+0.05* s ) ) ) ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
xtitle ( u n c o m p e n s a t e d s y s t e m )
[ gm , freqGM ]= g_margin ( G ) ;
[ pm , freqPM ]= p_margin ( G ) ;
disp ( gm , g a i n m a r g i n= ) ;
disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
disp ( pm , p h a s e m a r g i n= ) ;
disp (( freqPM *2* %pi ) ,
p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y = )
;
disp ( s i n c e P .M i s n e g a a t i v e s o s y s t e m i s u n s t a b l e
)
disp ( s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t
w=5 r a d / s e c and p o l e a t w=54 r a d / s e c and a p p l y i n g
gain to account a t t e n u a t i n f a c t o r . )
gc =(1+0.2* s ) /(1+0.0186* s )
Gc = syslin ( c , gc )
disp ( Gc , t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r= ) ;
G1 = G * Gc
disp ( G1 , o v e r a l l t r a n s f e r f u n c t i o n= ) ;
fmin =0.01;
fmax =100;
141
142
143
23
24
25
26
27
// c a p t i o n : d e s i g n s u i t a b l e c o m p e n s a t o r
// e x a m p l e 8 . 6 . 3
// p a g e 344
clc ;
s = %s ;
clf () ;
syms K ;
g =( K /( s *(1+0.5* s ) *(1+0.2* s ) ) ) ;
Kv =1/0.125 // s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t ( Kv=
d e s i r e d output v e l o c i t y / steady s t a t e e r r o r )
// s i n c e Kv=8 , a s s y s t e m i s t y p e 1 , s o K=Kv ;
K =8;
g =(8/( s *(1+0.5* s ) *(1+0.2* s ) ) ) ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
xtitle ( u n c o m p e n s a t e d s y s t e m )
[ gm , freqGM ]= g_margin ( G ) ;
[ pm , freqPM ]= p_margin ( G ) ;
disp ( gm , g a i n m a r g i n= ) ;
disp (( freqGM *2* %pi ) ,
g a i n m a r g i n f r e q o r p h a s e c r o s s o v e r f r e q u e n c y==
);
disp ( pm , p h a s e m a r g i n= ) ;
disp (( freqPM *2* %pi ) ,
p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y = )
;
disp ( s i n c e g a i n c r o s s o v e r f r e q and p h a s e c r o s s o v e r
f r e q a r e v e r y c l o s e t o e a c h o t h e r . So , s y s t e m i s
m a r g i n a l l y s t a b l e );
disp ( s o we n e e d p h a s e l a g n e t w o r k )
disp ( s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t
w=0.18 r a d / s e c and p o l e a t w=0.04 r a d / s e c and
applying gain to account a t t e n u a t i n f a c t o r . )
144
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
gc =(1+5.55* s ) /(1+24.7* s )
Gc = syslin ( c , gc )
disp ( Gc , t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r= ) ;
G1 = G * Gc
disp ( G1 , o v e r a l l t r a n s f e r f u n c t i o n= ) ;
fmin =0.01;
fmax =100;
figure () ;
bode ( G1 , fmin , fmax )
show_margins ( G1 )
xtitle ( c o m p e n s a t e d s y s t e m )
[ gm , freqGM ]= g_margin ( G1 ) ;
[ pm , freqPM ]= p_margin ( G1 ) ;
disp ( gm , g a i n m a r g i n= ) ;
disp (( freqGM *2* %pi ) ,
g a i n m a r g i n f r e q o r p h a s e c r o s s o v e r f r e q u e n c y==
);
43 disp ( pm , p h a s e m a r g i n o f c o m p e n s a t e d s y s t e m= ) ;
44 disp (( freqPM *2* %pi ) , g a i n c r o s s o v e r f r e q u e n c y = ) ;
145
146
147
Chapter 9
INTRODUCTION TO STATE
SPACE ANALYSIS OF
CONTROL SYSTEMS
1
2
3
4
5
6
7
8
9
10
148
1
2
3
4
5
6
7
8
9
10
149
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 9 . 1 0 . 4 a
// p a g e 387
s = %s ;
g =1/(( s +1) *( s +3) ) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
150
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 9 . 1 0 . 4 b
// p a g e 387
clc ;
s = %s ;
g =(2* s +1) /( s ^2+2) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 9 . 1 0 . 5
// p a g e 388
s = %s ;
g =( s +3) /( s ^2+3* s +4) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
151
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 9 . 1 0 . 6
// p a g e 389
s = %s ;
g =( s ^2+3* s +2) /( s ^3+9* s ^2+26* s +24) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 9 . 1 0 . 7
// p a g e 390
s = %s ;
g =( s +3) /(( s +1) *( s +2) ) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 9 . 1 0 . 9
// p a g e 392
152
4
5
6
7
8
9
10
11
s = %s ;
g =(10*( s +3) ) /(( s +4) *( s +2) ^2) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 9 . 1 0 . 1 0
// p a g e 393
s = %s ;
g =( s ^2+6* s +8) /(( s +3) *( s ^2+2* s +5) ) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
// c a p t i o n : o b t a i n t i m e r e s p o n s e
// e x a m p l e 9 . 1 0 . 1 1
// p a g e 394
s = %s ;
syms t
A =[0 1; -2 0]
B =[1 -1]
x0 =[1 1]
153
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
// f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x
ip =[0 0;0 0]
i =1; j =1;
for i =1:2
for j =1:2
ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ;
j = j +1;
end
i = i +1;
end
disp ( ip , s t a t e t r a n s i s t i o n m a t r i x , i p ( t )= ) ;
x = ip * x0
y = x (1 ,1) -x (2 ,1)
y = simple ( y ) // o u t p u t
disp (y , t i m e r e s p o n s e o f t h e system , y ( t )= ) ;
// c a p t i o n : o b t a i n z e r o i n p u t r e s p o n s e
// e x a m p l e 9 . 1 0 . 1 2 ( i )
// p a g e 395
s = %s ;
syms t
A =[0 1; -2 -1]
B =[0 1]
x0 =[1 0]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
// f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x
154
14
15
16
17
18
19
20
21
22
23
24
25
ip =[0 0;0 0]
i =1; j =1;
for i =1:2
for j =1:2
ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ;
j = j +1;
end
i = i +1;
end
disp ( ip , s t a t e t r a n s i s t i o n m a t r i x , i p ( t )= ) ;
x = ip * x0
disp (x , z e r o i n p u t r e s p o n s e o f t h e system , x ( t )= ) ;
// c a p t i o n : o b t a i n z e r o s t a t e r e s p o n s e
// e x a m p l e 9 . 1 0 . 1 2 ( i i )
// p a g e 395
s = %s ;
syms t
A =[0 1; -2 -1]
B =[0 1]
x0 =[1 0]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
m = r * B *(1/ s ) ;
// f o r c a l c u l a t i n g z e r o s t a t e r e s p o n s e
x =[0;0]
x (1 ,1) = ilaplace ( m (1 ,1) ,s , t ) ;
x (2 ,1) = ilaplace ( m (2 ,1) ,s , t ) ;
disp (x , z e r o i n p u t r e s p o n s e o f t h e system , x ( t )= ) ;
155
// c a p t i o n : o b t a i n t i m e r e s p o n s e
// e x a m p l e 9 . 1 0 . 1 3
// p a g e 397
syms t ;
A =[0 1; -2 0]
x0 =[1 1]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
// s i n c e exp ( At )=I+A t +(A t ) 2/2+(A t ) 3 / 3 + . . .
I = eye (r , c )
p = I + A * t +( A * t ) ^2/2+( A * t ) ^3/3
x = p * x0 ;
disp ( x (1 ,1) , t i m e r e s p o n s e o f t h e system , x1 ( t )= ) ;
disp ( x (2 ,1) , t i m e r e s p o n s e o f t h e system , x2 ( t )= ) ;
Scilab code Exa 9.10.14 Obtain Time Response using Diagonalization Process
1
2
3
4
5
6
7
8
9
10
11
// c a p t i o n :
obtain time response using diagonalization process
// e x a m p l e 9 . 1 0 . 1 4
// p a g e 398
syms m11 m22 m21 m12 t ;
s = %s ;
poly (0 , l ) ;
A =[1 4; -2 -5]
B =[0;1]
C =[1;0]
x0 =[1 0]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
156
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
I = eye (r , c ) ;
p = l *I - A ; // l IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f l I A
// r o o t s o f q a r e 1 and 3
l1 = -1;
l2 = -3;
// f o r d e t e r m i n i n g modal m a t r i x
x1 =[ m11 ; m21 ]
q1 =( l1 *I - A ) * x1
// on s o l v i n g we f i n d m11=1 , m21=0.5
m11 =1; m21 = -0.5
x2 =[ m12 ; m22 ]
q2 =( l2 *I - A ) * x1
// on s o l v i n g we f i n d m12=1 , m22=1
m12 =1; m22 = -1
M =[ m11 m12 ; m21 m22 ]
M1 = inv ( M ) ;
k1 = M1 * A * M ;
z0 = M1 * x0 ;
k2 = M1 * B
Z = inv ( s *I - k1 ) * z0 +( inv ( s *I - k1 ) * k2 ) *(1/ s ) ;
X=M*Z
x =[0;0]
x (1 ,1) = ilaplace ( X (1 ,1) ,s , t ) ;
x (2 ,1) = ilaplace ( X (2 ,1) ,s , t ) ;
y=C*x
disp (y , o u t p u t e q u a t i o n i s , y ( t )= )
Scilab code Exa 9.10.15 Obtain Time Response using Diagonalization Process
1
// c a p t i o n :
obtain time response using diagonalization process
157
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// e x a m p l e 9 . 1 0 . 1 5
// p a g e 403
syms t ;
s = %s ;
poly (0 , l ) ;
A =[0 1; -6 -5]
B =[0;1]
C =[6 1]
x0 =[1 0]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
I = eye (r , c ) ;
p = l *I - A ; // l IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f l I A
// r o o t s o f q a r e 1 and 3
l1 = -2;
l2 = -3;
// f o r d e t e r m i n i n g vandermonde s m a t r i x
P =[1 1; l1 l2 ];
P1 = inv ( P ) ;
k1 = P1 * A * P ;
z0 = P1 * x0 ;
k2 = P1 * B
Z = inv ( s *I - k1 ) * z0 +( inv ( s *I - k1 ) * k2 ) *(1/ s ) ;
X=P*Z
X (2 ,1) = -5/( s ^2+5* s +6)
x =[0;0]
x (1 ,1) = ilaplace ( X (1 ,1) ,s , t ) ;
x (2 ,1) = ilaplace ( X (2 ,1) ,s , t ) ;
y=C*x
y = simple ( y )
disp (y , o u t p u t e q u a t i o n i s , y ( t )= )
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x
158
2
3
4
5
6
7
8
9
10
11
12
13
// e x a m p l e 9 . 1 0 . 1 6
// p a g e 406
clc ;
s = %s
A =[1 -2;4 -5]
B =[2;1]
C =[1 1]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
r = inv ( p ) // i n v e r s e o f s I A
G = C * r * B // t r a n s f e r m a t r i x
disp (G , t r a n s f e r m a t r i x= )
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x
// e x a m p l e 9 . 1 0 . 1 7
// p a g e 407
s = %s
A =[ -3 1;0 -1]
B =[1;1]
C =[1 1]
D =0;
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
r = inv ( p ) // i n v e r s e o f s I A
G = C * r * B // t r a n s f e r m a t r i x
disp (G , t r a n s f e r m a t r i x= )
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x
// e x a m p l e 9 . 1 0 . 1 7
159
3
4
5
6
7
8
9
10
11
12
13
// p a g e 407
s = %s
A =[0 3; -2 -5]
B =[1 1;1 1]
C =[2 1;1 0]
D =0;
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
r = inv ( p ) // i n v e r s e o f s I A
G = C * r * B // t r a n s f e r m a t r i x
disp (G , t r a n s f e r m a t r i x= )
9
10
11
12
13
14
// c a p t i o n : c h e c k f o r c o n t r a l l a b i l i t y o f s y s t e m
// e x a m p l e 9 . 1 0 . 2 0
// p a g e 410
A =[0 1 0;0 0 1;0 -2 -3]
B =[0 1;0 0;1 1]
P = cont_mat (A , B ) ;
disp (P , C o n t r o l l a b i l i t y M a t r i x= ) ;
S =[ P (1) P (4) P (7) ; P (2) P (5) P (8) ; P (3) P (6) P (9) ]; //
c o l l e c t i n g c o l u m n s from P t o form a s q u a r e m a t r i x
(33)
d = det ( S ) ;
if d ==0
printf ( m a t r i x i s s i n g u l a r , s o s y s t e m i s
u n c o n t r o l l a b l e );
else
printf ( s y s t e m i s c o n t r o l l a b l e ) ;
end ;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// c a p t i o n :
check for contrallability and observability of system
// e x a m p l e 9 . 1 0 . 2 1
// p a g e 411
A =[0 1 0;0 0 1; -6 -11 -6]
B =[1 0 1]
C =[10 5 1]
P = cont_mat (A , B ) ;
disp (P , C o n t r o l l a b i l i t y M a t r i x= ) ;
d = det ( P )
if d ==0
printf ( m a t r i x i s s i n g u l a r , s o s y s t e m i s
u n c o n t r o l l a b l e );
else
printf ( s y s t e m i s c o n t r o l l a b l e ) ;
end ;
P1 = obsv_mat (A , C ) ;
disp ( P1 , O b s e r v a b i l i t y M a t r i x= ) ;
d1 = det ( P1 )
if d1 ==0
printf ( m a t r i x i s s i n g u l a r , s o s y s t e m i s
u n o b s e r v a b l e );
else
printf ( s y s t e m i s o b s e r v a b l e ) ;
end ;
// c a p t i o n :
check for contrallability and observability of system
2 // e x a m p l e 9 . 1 0 . 2 1
3 // p a g e 411
4 s = %s ;
161
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
162
Chapter 11
SOLUTION OF PROBLEMS
USING COMPUTER
// C a p t i o n : p o l e z e r o p l o t
// e x a m p l e 11 1
// p a g e 468
// t r a n s f e r f u n c t i o n :G( s ) = ( ( 8 ( s +3) ( s +4) ) / ( s ( s +2) (
s 2+2 s +2) ) )
s = %s ;
G = syslin ( c ,((8*( s +3) *( s +4) ) /( s *( s +2) *( s ^2+2* s +2) ) )
);
disp (G , G( s )= ) ;
x = plzr ( G )
xgrid (2)
163
164
1
2
3
4
5
6
7
8
9
10
11
12
13
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 11 2
// p a g e 469
syms G1 G2 G3 H1 ;
s = %s ;
G1 =4/( s *( s +4) ) ;
G2 = s +1.2;
G3 = s +0.8;
H1 =1;
H2 =( G2 + G3 ) ;
a = G1 /. H1 ;
y = a /(1+ a * H2 )
disp (y , C( s ) /R( s )= )
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 11 3
// p a g e 470
syms G1 G2 G3 H1 ;
s = %s ;
G1 =4;
G2 = s
G3 =1/( s *( s +2) ) ;
H1 =0.5;
H2 =1;
a =( G1 + G2 ) ;
b =( a * G3 ) ;
c = b /. H1 ;
y = c /(1+ c * H2 )
disp (y , C( s ) /R( s )= )
// c a p t i o n : determine Wn , z e t a a n d M p
// e x a m p l e 11 4
// p a g e 471
s = %s ;
num =1;
den = sym ( s ( 1 + 0 . 5 s ) ( 1 + 0 . 2 s ) ) ;
c = num / den ;
c = simple ( c ) ;
disp (c , C( s ) /E( s )= ) ;
G=c;
H =1;
CL = G /(1+ G * H ) ;
CL = simple ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
A = pfss ((10/( s ^3+7* s ^2+10* s +10) ) ) ;
d = denom ( A (1) ) ;
b = coeff ( denom ( A (1) ) )
printf ( f o r o s c i l l a t o r y r o o t s : )
Wn = sqrt ( b (1 ,1) ) ; // n a t u r a l f r e q u e n c y
// 2 z e t a Wn= 1 . 5 ;
zeta =1.5/(2* Wn ) ; // damping r a t i o
Mp = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; //
% peak overshoot
23 disp ( Wn , n a t u r a l f r e q u e n c y ,Wn= ) ;
24 disp ( zeta , damping r a t i o , z e t a= ) ;
25 disp ( Mp , % p e a k o v e r s h o o t , Mp= ) ;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Scilab code Exa 11.5 time response for unit step function
1 // C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n
2 // e x a m p l e 11 6
3 // p a g e 474
4 s = %s ;
5 syms t ;
6 G =( s +2) /( s *( s +1) )
166
7
8
9
10
11
12
13
14
15
16
17
18
19
H =1;
CL = G /. H
disp ( CL , C( s ) /R( s )= )
y = ilaplace ( CL ,s , t ) ;
disp (y , c ( t )= ) ;
b = denom ( CL )
c = coeff ( b )
//Wn2= c ( 1 , 1 )
Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=c ( 1 , 2 )
zeta = c (1 ,2) /(2* Wn ) // damping r a t i o
Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y
tr =( %pi - atan ( sqrt (1 - zeta ^2) / zeta ) ) /( Wn * sqrt (1 - zeta
^2) )
20 Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max .
overshoot
21 disp ( tr , r i s e t i m e= ) ;
22 disp ( Mp , max . peak o v e r s h o o t= ) ;
Scilab code Exa 11.7 time response for unit step function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n
// e x a m p l e 11 7
// p a g e 475
s = %s ;
syms t ;
CL =( s +2) /( s ^2+2* s +2)
disp ( CL , C( s ) /R( s )= )
y = ilaplace ( CL ,s , t ) ;
disp (y , c ( t )= ) ;
b = denom ( CL )
c = coeff ( b )
//Wn2= c ( 1 , 1 )
Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=c ( 1 , 2 )
167
overshoot
19 disp ( Tp , peak t i m e= ) ;
20 disp ( Mp , max . peak o v e r s h o o t= )
Scilab code Exa 11.8 time response for unit step function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n
// e x a m p l e 11 8
// p a g e 476
s = %s ;
syms t ;
G =(20) /(( s +1) *( s +5) )
H =1;
CL = G /. H
disp ( CL , C( s ) /R( s )= )
y = ilaplace ( CL ,s , t ) ;
disp (y , c ( t )= ) ;
b = denom ( CL )
c = coeff ( b )
//Wn2= c ( 1 , 1 )
Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=c ( 1 , 2 )
zeta = c (1 ,2) /(2* Wn ) // damping r a t i o
Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y
Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max .
overshoot
Tp = %pi / Wd // peak t i m e
t =(2* %pi ) /( Wn * sqrt (1 - zeta ^2) ) // p e r i o d o f o s c i l l a t i o n
ts =4/( zeta * Wn ) // s e t t l i n g t i m e
N = Wd /(2* %pi ) * ts // no . o f o s c i l l a t i o n s c o m p l e t e d
before reaching steady state
168
disp ( Tp , peak t i m e= ) ;
disp ( Mp , max . peak o v e r s h o o t= ) ;
disp (t , p e r i o d o f o s c i l l a t i o n ) ;
disp (N , no . o f o s c i l l a t i o n s c o m p l e t e d b e f o r e
r e a c h i n g s t e a d y s t a t e= ) ;
28 disp ( ts , s e t t l i n g t i m e= )
24
25
26
27
Scilab code Exa 11.9 time response for unit step function
// C a p t i o n : t i m e r e s p o n s e f o r u n i t s t e p f u n c t i o n
// e x a m p l e 11 9
// p a g e 476
s = %s ;
syms t ;
CL =(4* s +4) /( s ^2+2* s +5)
disp ( CL , C( s ) /R( s )= )
y = ilaplace ( CL ,s , t ) ;
disp (y , c ( t )= ) ;
b = denom ( CL )
c = coeff ( b )
//Wn2= c ( 1 , 1 )
Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=c ( 1 , 2 )
zeta = c (1 ,2) /(2* Wn ) // damping r a t i o
Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y
Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max .
overshoot
18 Tp = %pi / Wd // peak t i m e
19 disp ( Tp , peak t i m e= ) ;
20 disp ( Mp , max . peak o v e r s h o o t= ) ;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// C a p t i o n : c a l c u l a t e t r , Tp , Mp
// e x a m p l e 11 1 0 a
// p a g e 478
s = %s ;
G =16/( s ^2+1.6* s )
H =1;
CL = G /. H
disp ( CL , C( s ) /R( s )= ) ;
b = denom ( CL )
c = coeff ( b )
//Wn2= c ( 1 , 1 )
Wn = sqrt ( c (1 ,1) ) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=c ( 1 , 2 )
zeta = c (1 ,2) /(2* Wn ) // damping r a t i o
Wd = Wn * sqrt (1 - zeta ^2) // damped f r e q u e n c y
Mp =( exp ( -( zeta * %pi ) / sqrt (1 - zeta ^2) ) ) *100 //max .
overshoot
tr =( %pi - atan ( sqrt (1 - zeta ^2) / zeta ) ) /( Wn * sqrt (1 - zeta
^2) ) // r i s e t i m e
Tp = %pi / Wd // peak t i m e
disp ( Tp , peak t i m e= ) ;
disp ( Mp , max . peak o v e r s h o o t= )
disp ( tr , r i s e t i m e= )
// C a p t i o n : c a l c u l a t e T d , t r , Tp , Mp
// e x a m p l e 11 1 0 b
// p a g e 478
s = %s ;
syms Td
G =16/( s ^2+1.6* s )
G1 =1+ s * Td
H =1;
a = G * G1
170
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CL = a /. H
CL = simple ( CL )
disp ( CL , C( s ) /R( s )= ) ;
zeta =0.8 // g i v e n
// s i n c e z e t a =0.8 s o 2 z e t a Wn=1.6+16Td
Wn = sqrt (16)
// s o on s o l v i n g
Td =0.3
// s o t r a n s f e r f u n c t i o n t a k e s t h e form :
CL1 =(16+4.8* s ) /( s ^2+6.4* s +6)
disp ( CL1 , C( s ) /R( s )= ) ;
Wn1 = sqrt (16)
// 2 z e t a 1 Wn1=6.4
zeta1 =6.4/(2* Wn1 ) // damping r a t i o
Wd = Wn1 * sqrt (1 - zeta1 ^2) // damped f r e q u e n c y
Mp =( exp ( -( zeta1 * %pi ) / sqrt (1 - zeta1 ^2) ) ) *100 //max .
overshoot
tr =( %pi - atan ( sqrt (1 - zeta1 ^2) / zeta1 ) ) /( Wn1 * sqrt (1 zeta1 ^2) ) // r i s e t i m e
Tp = %pi / Wd // peak t i m e
disp ( Tp , peak t i m e= ) ;
disp ( Mp , max . peak o v e r s h o o t= )
disp ( tr , r i s e t i m e= )
// C a p t i o n : e x p r e s s i o n f o r u n i t s t e p r e s p o n s e
// e x a m p l e 11 1 1
// p a g e 481
syms G1 G2 G3 H1 t ;
s = %s ;
G1 = s +1;
G2 =1/( s +2) ;
H2 =1/( s *( s +1) ) ;
H1 =1/( s +2) ;
171
10
11
12
13
14
15
16
17
a = G1 /(1+ G1 * H1 ) ;
b = a /(1+ a * H2 )
y = b * G2 ;
disp (y , C( s ) /R( s )= )
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
C = y *(1/ s )
c = ilaplace (C ,s , t )
disp (c , e x p r e s s i o n f o r u n i t s t e p r e s p o n s e i s = )
// C a p t i o n : u n i t s t e p a n d i m p u l s e r e s p o n s e
// e x a m p l e 11 1 2
// p a g e 482
s = %s ;
syms t ;
G =(4* s +1) /(4* s ^2)
H =1;
CL = G /. H
disp ( CL , C( s ) /R( s )= )
y = ilaplace ( CL ,s , t ) ;
disp (y , u n i t i m p u l s e r e s p o n s e , c ( t )= ) ;
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
C = CL *(1/ s )
c = ilaplace (C ,s , t )
disp (c , e x p r e s s i o n f o r u n i t s t e p r e s p o n s e i s = )
// C a p t i o n : d e t e r m i n e t r a n s f e r f u n c t i o n
// e x a m p l e 11 1 3
// p a g e 483
syms t ;
172
Scilab code Exa 11.14 determine Wn Wd Tp zeta and steady state error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// c a p t i o n : determine Wn ,Wd, Tp ,
zeta and steady state error
// e x a m p l e 11 1 4
// p a g e 484
s = %s ;
syms t ;
G =20/(( s +5) *( s +1) )
H =1;
CL = G /. H
disp ( CL , C( s ) /R( s )= )
b = denom ( CL )
disp (0 ,b , = , t h e c h a r . eq i s : ,)
Wn = sqrt (25) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=6
zeta =6/(2* Wn ) ; // damping r a t i o
d = zeta * Wn ; // d a m p i n g f a c t o r
z = sqrt (1 - zeta ^2) ;
Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n
Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t
Tp = %pi / Wd // peak t i m e
tfirst =(2* %pi ) / Wd
// t i m e f o r f i r s t u n d e r s h o o t
period =(2* %pi ) / Wd
// p e r i o d o f o s c i l l a t i o n
ts =4/( zeta * Wn ) // s e t t l i n g t i m e
N =( Wd /(2* %pi ) ) * ts // no . o f o s c i l l a t i o n s c o m p l e t e d
before reaching steady state
disp ( Wn , n a t u r a l f r e q u e n c y= ) ;
disp ( zeta , damping r a t i o = ) ;
disp ( Wd , damped f r e q u e n c y o f o s c i l l a t i o n = ) ;
disp ( Tp , peak t i m e= ) ;
173
28
29
30
31
Scilab code Exa 11.15 determine Wn Wd zeta and steady state error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// c a p t i o n : determine Wn ,Wd,
zeta and steady state error
// e x a m p l e 11 1 5
// p a g e 484
s = %s ;
G = sym ( 2 5 / ( s ( s +5) ) ) ;
G = simple ( G ) ;
H =1;
CL = G /. H ;
CL = simple ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
printf ( t h e c h a r . eq i s : )
disp ( s 2+5 s +25 )
Wn = sqrt (25) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=5
zeta =5/(2* Wn ) ; // damping r a t i o
d = zeta * Wn ; // d a m p i n g f a c t o r
z = sqrt (1 - zeta ^2) ;
Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n
Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t
// s t e a d y s t a t e e r r o r f o r u n i t ramp i n p u t i s : E s s= ( 2
z e t a /Wn)
Ess =(2* zeta / Wn ) ; // s t e a d y s t a t e e r r o r
disp ( p a r t ( a ) : )
disp ( Wn , n a t u r a l f r e q u e n c y= ) ;
disp ( zeta , damping r a t i o = ) ;
disp ( Wd , d a m p e d f r e q u e n c y o f o s c i l l a t i o n= ) ;
174
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
disp ( Mp , % max . p e a k o v e r s h o o t= ) ;
disp ( Ess , s t e a d y s t a t e e r r o r= ) ;
// i f damping r a t i o i s i n c r e a s e d from 0 . 5 t o 0 . 7 5 by
i n c o r p o r a t i n g tachometer feedback
zeta =0.75;
H1 = sym ( s Kt ) // t a c h o m e t e r f e e d b a c k
CL1 = G /(1+ G * H1 ) ;
CL1 = simple ( CL1 ) ;
CL2 = CL1 /(1+ H * CL1 ) ;
CL2 = simple ( CL2 ) ;
disp ( CL2 , C( s ) /R( s )= ) ;
Wn = sqrt (25) ;
// 2 z e t a Wn=25Kt +5;
Kt =(2* zeta * Wn -5) /25; // t a c h o m e t e r g a i n
Mp1 = exp (( - zeta * %pi ) / sqrt (1 - zeta ^2) ) *100; //
% peak overshoot
disp ( A f t e r a p p l y i n g t a c h o m e t e r f e e d b a c k : )
disp ( Kt , t a c h o m e t e r g a i n= ) ;
disp ( Mp1 , % p e a k o v e r s h o o t= ) ;
1
2
3
4
5
6
7
8
9
10
11
175
13 Kv = limit ( s * GH ,s ,0) ; // s t a t i c
velocity error
coefficient
14 disp ( Kv , s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t = ) ;
15 Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
coefficient
16 disp ( Ka , s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t = ) ;
// c a p t i o n : d e t e r m i n e K p K v K a
// e x a m p l e 11 1 6
// p a g e 485
s = %s ;
syms t ;
num = sym ( 1 0 0 ( s +2) ( s +40) ) ;
den = sym ( ( s 3 ( s 2+4 s +200) ) ) ;
GH = num / den ;
GH = simple ( GH ) ;
disp ( GH , G( s )H( s )= ) ;
Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r
coefficient
disp ( Kp , s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t = ) ;
Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r
coefficient
disp ( Kv , s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t = ) ;
Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
coefficient
disp ( Ka , s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t = ) ;
// c a p t i o n : d e t e r m i n e K p K v K a
// e x a m p l e 11 1 8
176
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// p a g e 488
s = %s ;
syms t ;
num = sym ( 2 ( s 2+3 s +20) ) ;
den = sym ( s ( s +2) ( s 2+4 s +10) ) ;
GH = num / den ;
GH = simple ( GH ) ;
disp ( GH , G( s )H( s )= ) ;
input1 =5;
Kp = limit ( GH ,s ,0) ; // s t a t i c p o s i t i o n a l e r r o r
coefficient
Ess =5*(1/(1+ Kp ) ) ; // s t e a d y s t a t e e r r o r
e =(1/( %inf +1) ) ;
e =0;
Ess = e ;
disp ( Kp , s t a t i c p o s i t i o n a l e r r o r c o e f f i c i e n t = ) ;
disp ( Ess , s t e a d y s t a t e e r r o r= ) ;
input2 =4* t ;
Kv = limit ( s * GH ,s ,0) ; // s t a t i c v e l o c i t y e r r o r
coefficient
Ess =(1/ Kv ) *4; // s t e a d y s t a t e e r r o r
disp ( Kv , s t a t i c v e l o c i t y e r r o r c o e f f i c i e n t = ) ;
disp ( Ess , s t e a d y s t a t e e r r o r= ) ;
input3 =(4* t ^2) /2;
Ka = limit ( s ^2* GH ,s ,0) ; // s t a t i c a c c e l e r a t i o n e r r o r
coefficient
Ess =(1/ Ka ) *4; // s t e a d y s t a t e e r r o r
disp ( Ka , s t a t i c a c c e l e r a t i o n e r r o r c o e f f i c i e n t = ) ;
disp ( s t e a d y s t a t e e r r o r= ) ;
disp ( i n f i n i t y )
// C a p t i o n : d e t e r m i n e t r a n s f e r f u n c t i o n
// e x a m p l e 11 1 9
177
3 // p a g e 489
4 syms t ;
5 s = %s ;
6 c =0.5+(1.25* exp ( - t ) ) -(1.75* exp ( -12* t ) ) ;
7 C = laplace (c ,t , s ) ;
8 disp (C , C( s )= )
// C a p t i o n : r o o t s o f c h a r a c t e r s t i c s e q u a t i o n
// e x a m p l e 11 2 1 a
// p a g e 491
s = %s ;
num =210
den = sym ( s ( s +2) ( s 2+12 s +6) ) ;
G = num / den ;
G = simple ( G ) ;
H =1;
n1 = poly ([210] , s , c o e f f ) ;
d1 = poly ([210 192 390 44 1] , s , c o e f f ) ;
CL = syslin ( c ,n1 , d1 )
disp ( CL , C( s ) /R( s )= )
b = denom ( CL )
disp (0 , = ,b , t h e c h a r . eq i s : ,)
r = roots ( b ) ;
disp (r , r o o t s o f c h a r . eq . a r e= ) ;
// C a p t i o n : b o d e p l o t
// e x a m p l e 11 2 1 b
178
179
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// p a g e 491
s = %s ;
num =210
den =( s *( s +2) *( s ^2+12* s +6) ) ;
g = num / den ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
gm = g_margin ( G )
pm = p_margin ( G )
disp ( gm , g a i n m a r g i n= ) ;
disp ( pm , p h a s e m a r g i n= ) ;
// c a p t i o n : g a i n m a r g i n a n d p h a s e m a r g i n
// e x a m p l e 11 2 2
// p a g e 493
s = %s ;
g =((2*( s +0.25) ) /( s ^2*( s +1) *( s +0.5) ) ) ;
G = syslin ( c ,g )
fmin =0.1;
fmax =100;
bode (G , fmin , fmax )
[ gm , freqGM ]= g_margin ( G ) ;
[ pm , freqPM ]= p_margin ( G ) ;
show_margins ( G ) ;
disp ( gm , g a i n m a r g i n= ) ;
disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
disp ( pm , p h a s e m a r g i n= ) ;
disp (( freqPM *2* %pi ) , p h a s e m a r g i n f r e q= ) ;
180
181
show_margins ( G ) ;
disp ( s i n c e g a i n and p h a s e m a r g i n a r e b o t h n e g a t i v e
so system i s u n s t a b l e )
182
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
s1 = - s ;
g =50/(( s +1) *( s +2) ) ;
g1 =50/(( s1 +1) *( s1 +2) ) ;
GH = syslin ( c ,g )
GH1 = syslin ( c , g1 )
nyquist ( GH ) ;
nyquist ( GH1 ) ;
mtlb_axis ([ -5 30 -20 20]) ;
xtitle ( N y q u i s t p l o t o f 5 0 / ( ( s +1) ( s +2) ) )
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s n o t e n c i r c l e d by
N y q u i s t p l o t , s o N=0 and P=0( g i v e n ) )
N =0; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s ) p l o t
P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s s t a b l e . )
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 11 2 5
// p a g e 497
clf () ;
s = %s ;
s1 = - s ;
g =(2.2/( s *( s +1) *( s ^2+2* s +2) ) )
g1 =(2.2/( s1 *( s1 +1) *( s1 ^2+2* s1 +2) ) )
183
184
1+%i 0 , s o s y s t e m i s m a r g i n a l l y s t a b l e and
output r e p r e s e n t s s u s t a i n e d o s c i l l a t i o n s . )
185
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 11 2 6 i
// p a g e 497
clf () ;
s = %s ;
s1 = - s ;
disp ( f o r K=10 )
g =(10*( s -1) ) /(( s +2) *( s +3) ) ;
g1 =(10*( s1 -1) ) /(( s1 +2) *( s1 +3) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
mtlb_axis ([ -2 2 -2.5 2.5]) ;
xtitle ( N y q u i s t p l o t o f ( 1 0 ( s 1) ) / ( ( s +2) ( s +3) ) ; )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s
encircled
c l o c k w i s e by N y q u i s t p l o t , s o N=1 and P=1( g i v e n )
)
N = -1; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s )
plot anticlockwise
P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=1 , t h e r e i s one r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s u n s t a b l e . )
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 11 2 6 i i
186
187
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// p a g e 497
clf () ;
s = %s ;
s1 = - s ;
disp ( f o r K=4 )
g =(4*( s -1) ) /(( s +2) *( s +3) ) ;
g1 =(4*( s1 -1) ) /(( s1 +2) *( s1 +3) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
mtlb_axis ([ -1 1 -1 1]) ;
xtitle ( N y q u i s t p l o t o f ( 2 . 5 ( s +1) ) / ( ( s + 0 . 5 ) ( s 2) )
)
disp ( s i n c e t h e p o i n t (1+%i0 ) i s
encircled
a n t i c l o c k w i s e by N y q u i s t p l o t , s o N=1 and P=1(
given ) )
N =0; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s ) p l o t
anticlockwise
P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s s t a b l e . )
// c a p t i o n : r o o t l o c u s
// e x a m p l e 11 2 7
// p a g e 499
188
189
s = %s ;
clf () ;
g =(( s ^2+4) /( s *( s +1) ) ) ;
G = syslin ( c ,g )
evans (g ,200)
xgrid (2)
// c a p t i o n : r o o t l o c u s
// e x a m p l e 11 2 8
190
// p a g e 501
s = %s ;
clf () ;
g =1/( s *( s +2) *( s ^2+2* s +2) ) ;
G = syslin ( c ,g )
evans (g ,200)
xgrid (2)
// c a p t i o n : r o o t l o c u s
191
// c a p t i o n : r o o t l o c u s
192
2 // e x a m p l e 11 3 0
3 // p a g e 503
4 s = %s ;
5 g =1/( s *( s +4) *( s ^2+4* s +13) ) ;
6 G = syslin ( c ,g )
7 evans (g ,200)
8 xgrid (2)
// c a p t i o n : d e s i g n l e a d c o m p e n s a t o r
// e x a m p l e 11 3 1
// p a g e 339
s = %s ;
clf () ;
syms K ;
g =( K /( s *(1+0.2* s ) ) ) ;
Kv = limit ( s *g ,s ,0) ; // s t a t i c v e l o c i t y e r r o r
coefficient
// s i n c e Kv=10
K =10;
g =(10/( s *(1+0.2* s ) ) ) ;
G = syslin ( c ,g )
fmin =0.01;
fmax =100;
bode (G , fmin , fmax )
show_margins ( G )
[ gm , freqGM ]= g_margin ( G ) ;
[ pm , freqPM ]= p_margin ( G ) ;
disp ( gm , g a i n m a r g i n= ) ;
disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
disp ( pm , p h a s e m a r g i n= ) ;
disp (( freqPM *2* %pi ) ,
p h a s e m a r g i n f r e q o r g a i n c r o s s o v e r f r e q u e n c y = )
;
193
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
disp ( s i n c e P .M i s l e s s t h a n d e s i r e d v a l u e s o we
need phase l e a d network )
disp ( s e l e c t i n g z e r o o f l e a d c o m p e n s a t i n g n e t w o r k a t
w=5.5 r a d / s e c and p o l e a t w=13.8 r a d / s e c and
applying gain to account a t t e n u a t i n f a c t o r . )
gc =(1+0.18* s ) /(1+0.072* s )
Gc = syslin ( c , gc )
disp ( Gc , t r a n s f e r f u n c t i o n o f l e a d c o m p e n s a t o r= ) ;
G1 = G * Gc
disp ( G1 , o v e r a l l t r a n s f e r f u n c t i o n= ) ;
fmin =0.01;
fmax =100;
figure () ;
bode ( G1 , fmin , fmax ) ;
show_margins ( G1 )
[ gm , freqGM ]= g_margin ( G1 ) ;
[ pm , freqPM ]= p_margin ( G1 ) ;
disp ( pm , p h a s e m a r g i n o f c o m p e n s a t e d s y s t e m= ) ;
disp (( freqPM *2* %pi ) , g a i n c r o s s o v e r f r e q u e n c y = ) ;
// c a p t i o n : n i c h o l a s c h a r t
// e x a m p l e 11 3 2
// p a g e 507
s = %s ;
num =20;
den =( s *( s +2) *( s +5) )
g = num / den
194
195
196
197
8 G = syslin ( c ,g )
9 fmin =0.01
10 fmax =100
11 black (G , fmin , fmax )
12 xgrid (2)
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 11 3 3
// p a g e 509
s = %s ;
g =( s +2) /(( s +1) *( s +3) ) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 11 3 4
// p a g e 509
s = %s ;
g =( s ^2+ s +2) /( s ^3+9* s ^2+26* s +24) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
198
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 11 3 5
// p a g e 510
s = %s ;
g =1/( s ^2+2* s +5) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
// c a p t i o n : s t a t e t r a n s i t i o n m a t r i x
// e x a m p l e 11 3 6
// p a g e 511
s = %s ;
syms t
A =[1 4; -2 -5]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
// f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x
ip =[0 0;0 0]
i =1; j =1;
for i =1:2
for j =1:2
199
16
ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ;
17
j = j +1;
18
end
19
i = i +1;
20 end
21 disp ( ip , s t a t e t r a n s i s t i o n m a t r i x , i p ( t )= ) ;
// c a p t i o n : d e t e r m i n e t r a n s f e r f u n c t i o n
// e x a m p l e 11 3 8
// p a g e 513
s = %s
A =[ -5 1; -6 0]
B =[1;2]
C =[2 1]
200
8
9
10
11
12
13
D =0;
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
r = inv ( p ) // i n v e r s e o f s I A
G = C * r * B + D // t r a n s f e r m a t r i x
disp (G , t r a n s f e r m a t r i x= )
// c a p t i o n : d e t e r m i n e t r a n s f e r m a t r i x
// e x a m p l e 11 3 9
// p a g e 513
s = %s
A =[0 1; -6 -5]
B =[0;1]
C =[2 1]
D =0;
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
r = inv ( p ) // i n v e r s e o f s I A
G = C * r * B + D // t r a n s f e r m a t r i x
disp (G , t r a n s f e r m a t r i x= )
201
Chapter 12
CLASSIFIED SOLVED
EXAMPLES
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 1 2 . 1
// p a g e 515
// we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w
graph approach
syms G H ;
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 =1* G *1
P2 =1;
L1 = - G ;
L2 = - G * H ;
L3 = G * H ;
D1 =1;
D2 =1;
D =1 -( L1 + L2 + L3 ) ;
D = simple ( D )
202
17 Y =( P1 * D1 + P2 * D2 ) / D ;
18 Y = simple ( Y ) ;
19 disp (Y , C( s ) /R( s )= ) ;
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 1 2 . 2
// p a g e 516
// we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w
graph approach
syms G1 G2 G3 G4
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 ;
P2 = G2 ;
P3 = - G1 * G2 * G3 ;
P4 = G1 * G2 * G4 ;
L1 = - G1 * G2 * G3 * G4 ;
D1 =1;
D2 =1;
D3 =1;
D4 =1;
D =1 -( L1 ) ;
Y =( P1 * D1 + P2 * D2 + P3 * D3 + P4 * D4 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= ) ;
// C a p t i o n : t r a n s f e r f u n c t i o n
203
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// e x a m p l e 1 2 . 3
// p a g e 517
// we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w
graph approach
syms G1 G2 G3 G4 H2 H1 H3
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G2 * G4 ;
P2 = G2 * G3 * G4 ;
P3 = G1 * G3 * G4 ;
L1 = - G4 * H1 ;
L2 = - G3 * G4 * H1 * H2 ;
L3 = - G1 * G3 * G4 * H1 * H2 * H3
D1 =1;
D2 =1;
D3 =1;
D =1 -( L1 + L2 + L3 ) ;
Y =( P1 * D1 + P2 * D2 + P3 * D3 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= ) ;
204
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
P1 = G1 ;
P2 = G2 ;
P3 = G1 * G2 ;
P4 = G1 * G2 ;
L1 = - G1 ;
L2 = - G2 ;
L3 = G1 * G2 ;
L4 = - G1 * G2 ;
L5 = - G1 * G2 ;
D1 =1;
D2 =1;
D3 =1;
D4 =1;
D =1 -( L1 + L2 + L3 + L4 + L5 ) ;
Y =( P1 * D1 + P2 * D2 + P3 * D3 + P4 * D4 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= ) ;
// C a p t i o n : t r a n s f e r f u n c t i o n
// e x a m p l e 1 2 . 5
// p a g e 518
// we a r e s o l v i n g t h i s p r o b l e m from s i g n a l f l o w
graph approach
syms G1 G2 G3 G4 G5 H1 H2
// f o r w a r d p a t h d e n o t e d by P1 , P2 and s o on and l o o p
by L1 , L2 and s o on
// p a t h f a c t o r by D1 , D2 and s o on and g r a p h
d e t e r m i n a n t by D
P1 = G1 * G4 * G5 ;
P2 = G1 * G2 * G3 * G5 ;
L1 = - G3 * G5 ;
L2 = - G3 * G5 * H2 ;
L3 = - G1 * G4 * G5 * H1 ;
205
13
14
15
16
17
18
19
L4 = - G1 * G2 * G3 * G5 * H1 ;
D1 =1;
D2 =1;
D =1 -( L1 + L2 + L3 + L4 ) ;
Y =( P1 * D1 + P2 * D2 ) / D ;
Y = simple ( Y ) ;
disp (Y , C( s ) /R( s )= ) ;
Scilab code Exa 12.7 Determine Peak Time and Peak Overshoot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// C a p t i o n : d e t e r m i n e p e a k t i m e a n d p e a k o v e r s h o o t
// e x a m p l e 1 2 . 7
// p a g e 520
s = %s ;
syms t ;
G = sym ( ( s +2) / ( s ( s +1) ) ) //G( s )
H =1;
CL = G /(1+ G * H ) ;
disp ( CL , C( s ) /R( s )= ) ;
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
d = CL *(1/ s ) ;
a=s*d;
disp (d , C( s )= ) ;
c = ilaplace (d ,s , t ) ;
disp (c , c ( t )= ) ;
// f o r peak t i m e we g e t t p =3%pi /4
tp =3* %pi /4
Cmax =1 -( exp ( - tp ) * cos ( tp ) ) ;
Css = limit (a ,s ,0) ;
disp ( Css , Css= ) ;
Mp =(( Cmax - Css ) / Css ) *100
Mp = float ( Mp )
disp ( Mp , p e a k o v e r s h o o t= )
206
// C a p t i o n : t i m e r e s p o n s e a n d p e a k o v e r s h o o t
// e x a m p l e 1 2 . 8
// p a g e 521
s = %s ;
syms t ;
num = sym ( 8 ( s +1) ) ;
den = sym ( ( s 2+2 s +2) ) ;
CL = num / den ;
disp ( CL , C( s ) /R( s )= ) ;
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
d = CL *(1/ s ) ;
disp (d , C( s )= ) ;
c = ilaplace (d ,s , t ) ;
disp (c , c ( t )= ) ;
// f o r peak t i m e we g e t t p=%pi /2
t = %pi /2
a=s*d;
a = simple ( a )
Cmax =4*(1+1.414* exp ( - t ) * sin (t -( %pi /4) ) )
Css = limit (a ,s ,0) ;
disp ( Css , Css= ) ;
Mp =(( Cmax - Css ) / Css ) *100
Mp = float ( Mp )
disp ( Mp , p e a k o v e r s h o o t= )
// C a p t i o n : d e t e r m i n e p e a k o v e r s h o o t
// e x a m p l e 1 2 . 9
// p a g e 523
207
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
s = %s ;
syms t K ;
CL = sym ( ( s +1) / ( s 2+2 s +5) ) ;
CL = K * CL ;
disp ( CL , C( s ) /R( s )= )
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
d = CL *(1/ s )
Css = limit ( s *d ,s ,0)
disp ( Css , Css= ) ;
// s i n c e Css =0.8 ( g i v e n )
K =0.8*5;
CL = eval ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
d = CL *(1/ s )
disp (d , C( s )= ) ;
c = ilaplace (d ,s , t ) ;
disp (c , c ( t )= ) ;
// f o r peak t i m e we g e t t p = 0 . 7 8 5
t =0.785
a=s*d;
a = simple ( a )
Cmax =(4/5) *(1 - exp ( - t ) * cos (2* %pi /4) + exp ( - t ) *2* sin (2*
%pi /4) )
Css = limit (a ,s ,0)
disp ( Css , Css= ) ;
Mp =(( Cmax - Css ) / Css ) *100
Mp = float ( Mp )
disp ( Mp , p e a k o v e r s h o o t= )
// C a p t i o n : d e t e r m i n e u n i t s t e p r e s p o n s e
// e x a m p l e 1 2 . 1 0
// p a g e 524
208
4
5
6
7
8
9
10
11
12
s = %s ;
syms t ;
CL = sym ( 1 / ( ( s +1) ( s 2+1) ) )
disp ( CL , C( s ) /R( s )= ) ;
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
d = CL *(1/ s ) ;
a=s*d;
c = ilaplace (d ,s , t ) ;
disp (c , c ( t )= ) ;
Scilab code Exa 12.11 Determine Unit Step and Unit Impulse Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// C a p t i o n :
determine unit step and unit impulse response
// e x a m p l e 1 2 . 1 1
// p a g e 524
s = %s ;
syms t ;
G = sym ( 8 / ( s +1) ) ;
H = sym ( ( 1 / 2 s ) ) ;
CL = G /(1+ G * H ) ;
disp ( CL , C( s ) /R( s )= ) ;
// f o r u n i t s t e p r e s p o n s e R( s ) =1/ s ;
d = CL *(1/ s ) ;
disp (d , C( s )= ) ;
c = ilaplace (d ,s , t ) ;
disp (c , u n i t s t e p r e s p o n s e , c ( t )= ) ;
// f o r u n i t i m p u l s e r e s p o n s e R( s ) =1;
e = CL *(1) ;
disp (e , C( s )= ) ;
ct = ilaplace (e ,s , t ) ;
disp ( ct , u n i t i m p u l s e r e s p o n s e , c ( t )= ) ;
209
Scilab code Exa 12.12 Determine Wn Wd zeta and steady state error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// c a p t i o n : determine Wn ,Wd,
zeta and steady state error
// e x a m p l e 12 1 2
// p a g e 526
s = %s ;
G = sym ( 2 0 / ( s ( s 2+6 s +6) ) ) ;
H =0.25;
CL = G /(1+ G * H ) ;
CL = simple ( CL ) ;
disp ( CL , C( s ) /R( s )= ) ;
printf ( t h e c h a r . eq i s : )
disp ( s 2+ s +1=0 )
Wn = sqrt (1) // n a t u r a l f r e q u e n c y
// 2 z e t a Wn=1
zeta =1/(2* Wn ) ; // damping r a t i o
d = zeta * Wn ; // d a m p i n g f a c t o r
z = sqrt (1 - zeta ^2) ;
Wd = Wn * z ; // d a m p e d f r e q u e n c y o f o s c i l l a t i o n
Mp = exp (( - zeta * %pi ) / z ) *100; // % max . p e a k o v e r s h o o t
ts =4/( zeta * Wn ) ; // s e t t l i n g t i m e
tp = %pi /( Wn * sqrt (1 - zeta ^2) ) ; // p e a k t i m e
tu =2* %pi /( Wn * sqrt (1 - zeta ^2) ) ; // f i r s t u n d e r s h o o t
ti = tu - tp ; // t i m e i n t e r v a l b e t w e e n max . and min .
values
disp ( Wn , n a t u r a l f r e q u e n c y= ) ;
disp ( zeta , damping r a t i o = ) ;
disp ( Wd , d a m p e d f r e q u e n c y o f o s c i l l a t i o n= ) ;
disp ( Mp , % max . p e a k o v e r s h o o t= ) ;
disp ( ts , s e t t l i n g t i m e = ) ;
disp ( tp , p e a k t i m e= ) ;
disp ( ti , t i m e i n t e r v a l b e t w e e n m a x a n d m i n v a l u e s= )
;
210
Scilab code Exa 12.13 Determine Wn Wd zeta and steady state error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// c a p t i o n : determine Wn ,Wd,
zeta and steady state error
// e x a m p l e 12 1 3
// p a g e 527
syms Kp K Kd T
s = %s ;
// e x e c s e r i e s . s c e ;
// e x e c p a r a l l e l . s c e ;
a =( Kp + s * Kd ) * K
b =1/( s *( s * T +1) )
G = series (a , b )
H =1;
er =1/(1+ G * H )
disp ( er , E( s ) /R( s )= ) ;
R =1/ s ^2
E = R * er
ess = limit ( s *E ,s ,0)
disp ( ess , s t e a d y s t a t e e r r o r , e s s= )
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 1 2 . 1 5
// p a g e 529
s = %s ;
syms K
G = sym ( K/ ( s ( s 2+ s +1) ( s +5) ) ;
H =1;
CH =( s *( s ^2+ s +1) *( s +5) + K )
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
211
13
14
15
16
17
18
19
20
21
22
23
24
25
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) / routh (2 ,1) ) ,K ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0 ,0]
routh =[ routh ;K ,0 ,0]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be s t a b l e : ) ;
disp ( ( ( 5 . 1 5 6 K) / 5 . 1 ) >0 and K>0 ) ;
disp ( which g i v e s : ) ;
disp ( 0<K<4.25 ) ;
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 1 2 . 1 6
// p a g e 530
s = %s ;
syms K
CH = s ^4+2* s ^3+10* s ^2+( K -10) * s + K
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) / routh (2 ,1) ) ,K ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
212
// r o u t h =[ r o u t h ; K, 0 , 0 ]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be s t a b l e , f o l l o w i n g
c o n d i t i o n s h o u l d be s a t i s f i e d ) ;
23 disp ( K<30 ,K<22.9 and K> 1 3 . 1 ,K>0 )
24 disp ( which g i v e s , )
25 disp ( 13.1 <K<22.9 ) ;
20
21
22
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 1 2 . 1 7
// p a g e 530
s = %s ;
syms K
G = sym ( K/ ( ( s 3+3 s +2) ( s 2+6 s +24) ) ) ;
H =1;
CH =(( s ^3+3* s +2) *( s ^2+6* s +24) + K )
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh
(1 ,3) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
// r o u t h =[ r o u t h ; K, 0 , 0 ]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be s t a b l e , f o l l o w i n g
213
c o n d i t i o n s h o u l d be s a t i s f i e d ) ;
25 disp ( 7 8 . 8 4 0 . 2 5 9K>0 )
26 disp ( which g i v e s l i m i t i n g v a l u e o f K )
27 disp ( K< 2 8 8 . 9 ) ;
23
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 1 2 . 1 8
// p a g e 531
s = %s ;
A = s ^5+ s ^4+4* s ^3+4* s ^2+ s +1;
b = coeff ( A )
n = length ( b )
routh =[ b ([6 4 2]) ; b ([5 3 1]) ]
routh1 = routh ;
c =[ routh (1 ,1) , routh (1 ,3) ; routh (2 ,1) , routh (2 ,3) ]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,- det ( c )
/ routh (2 ,1) ,0]
disp ( s i n c e a l l e l e m e n t s o f t h i r d row a r e z e r o , s o
we make a u x i l i a r y e q u a t i o n )
A = sym ( s 4+4 s 2+1 ) // a u x i l i a r y e q u a t i o n
B = diff (A , s )
routh =[ routh1 ;4 ,8 ,0]
d =[ routh (2 ,1) , routh (2 ,3) ; routh (3 ,1) , routh (3 ,3) ]
routh =[ routh ; - det ( routh (2:3 ,1:2) ) / routh (3 ,1) ,- det ( d )
/ routh (3 ,1) ,0]
routh2 = routh
routh =[ routh ; - det ( routh (3:4 ,1:2) ) / routh (4 ,1) ,0 ,0]
routh =[ routh ; - det ( routh (4:5 ,1:2) ) / routh (5 ,1) ,0 ,0];
disp ( routh , r o u t h= )
disp ( s t a b i l i t y i s examined a s b e l o w . s i n c e r o o t s
o f a u x i l i a r y eq a r e a l s o r o o t s o f c h a r a c t e r s t i c s
eq )
A = s ^4+4* s ^2+1
214
24 b = roots ( A )
25 disp ( s i n c e t h e e q u a t i o n h a s non r e p e a t i n g
r o o t s on
are
// c a p t i o n : s t a b i l i t y u s i n g R o u t h h u r w i t z c r i t e r i o n
// e x a m p l e 1 2 . 1 9
// p a g e 531
s = %s ;
A = s ^5+ s ^4+4* s ^3+4* s ^2+4* s +4;
b = coeff ( A )
n = length ( b )
routh =[ b ([6 ,4 ,2]) ; b ([5 3 1]) ]
routh1 = routh ;
c =[ routh (1 ,1) , routh (1 ,3) ; routh (2 ,1) , routh (2 ,3) ]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) ,- det ( c )
/ routh (2 ,1) ,0]
disp ( s i n c e a l l e l e m e n t s o f t h i r d row a r e z e r o , s o
we make a u x i l i a r y e q u a t i o n )
A = sym ( s 4+4 s 2+4 ) // a u x i l i a r y e q u a t i o n
B = diff (A , s )
routh =[ routh1 ;4 ,8 ,0]
d =[ routh (2 ,1) , routh (2 ,3) ; routh (3 ,1) , routh (3 ,3) ]
routh =[ routh ; - det ( routh (2:3 ,1:2) ) / routh (3 ,1) ,- det ( d )
/ routh (3 ,1) ,0]
routh2 = routh
routh =[ routh ; - det ( routh (3:4 ,1:2) ) / routh (4 ,1) ,0 ,0]
disp ( s i n c e a l l e l e m e n t s o f f i f t h row a r e z e r o , s o
we make a u x i l i a r y e q u a t i o n )
A = sym ( 2 s 2+4 ) // a u x i l i a r y e q u a t i o n
B = diff (A , s )
routh =[ routh2 ;4 ,0 ,0]
routh =[ routh ; - det ( routh (4:5 ,1:2) ) / routh (5 ,1) ,0 ,0];
215
disp ( routh , r o u t h= )
disp ( s t a b i l i t y i s examined a s b e l o w . s i n c e r o o t s
o f a u x i l i a r y eq a r e a l s o r o o t s o f c h a r a c t e r s t i c s
eq )
27 A = s ^4+4* s ^2+4
28 b = roots ( A )
29 disp ( s i n c e t h e e q u a t i o n h a s m u l t i p l e r o o t s on s
plane imaginary a x i s . hence system are u n s t a b l e
)
25
26
// c a p t i o n : d e t e r m i n e f r e q u e n c y o f o s c i l l a t i o n s
// e x a m p l e 1 2 . 2 1
// p a g e 533
s = %s ;
syms K
G = sym ( K ( s ( 2 s +1) ) / ( s 3+3 s +20) ) ;
H =1;
CH =(( s ^3+3* s +20) + K *( s *(2* s +1) ) )
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
routh =[ b ([4 ,2]) ; b ([3 ,1]) ]
routh =[ routh ; - det ( routh (1:2 ,1:2) / routh (2 ,1) ) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0]
disp ( routh , r o u t h= )
disp ( f o r s u s t a i n e d o s c i l l a t i o n s : ) ;
disp ( 2K2+6K20=0 )
216
disp ( which g i v e s K )
disp ( K=2 ) ;
disp ( f r e q o f o s c i l l a t i o n s i s c a l c u l a t e d by s o l v i n g
e q u a t i o n f o r m e d by s 2 row o f t h e r o u t h t a b l e )
K =2
k =2
A =2* k * s ^2+20
r = roots ( A )
disp ( %i * r (2) , f r e q u e n c y o f o s c i l l a t i o n s = )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 12 2 3 i
// p a g e 535
clf () ;
s = %s ;
s1 = - s ;
disp ( f o r K=0.1 )
g =(0.1*( s +10) *( s +40) ) /( s *( s +1) *( s +4) ) ;
g1 =(0.1*( s1 +10) *( s1 +40) ) /( s1 *( s1 +1) *( s1 +4) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
// m t l b a x i s ( [ 1 . 5 0 . 2 0.3 0 . 3 ] ) ;
xtitle ( N y q u i s t p l o t o f ( 0 . 1 ( s +10) ( s +40) ) / ( s ( s +1)
( s +4) ) )
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s
not e n c i r c l e d
c l o c k w i s e by N y q u i s t p l o t , s o N=0 and P=0 )
N =0; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s ) p l o t
anticlockwise
P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s s t a b l e . )
218
219
220
16
17
18
19
20
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 12 2 3 i i
// p a g e 535
disp ( f o r K=1 )
g =(0.1*( s +10) *( s +40) ) /( s *( s +1) *( s +4) ) ;
g1 =(0.1*( s1 +10) *( s1 +40) ) /( s1 *( s1 +1) *( s1 +4) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
// m t l b a x i s ([ 3 0 . 5 0.6 0 . 6 ] ) ;
xtitle ( N y q u i s t p l o t o f ( 0 . 1 ( s +10) ( s +40) ) / ( s ( s +1)
( s +4) ) )
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s
encircled twice
c l o c k w i s e by N y q u i s t p l o t , s o N=2 and P=0( g i v e n )
)
N = -2; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s )
plot anticlockwise
P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=2 , t h e r e a r e two r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s u n s t a b l e . )
221
222
223
16
17
18
19
20
// c a p t i o n : s t a b i l i t y u s i n g N y q u i s t c r i t e r i o n
// e x a m p l e 12 2 3 i i i
// p a g e 535
disp ( f o r K=10 )
g =(10*( s +10) *( s +40) ) /( s *( s +1) *( s +4) ) ;
g1 =(10*( s1 +10) *( s1 +40) ) /( s1 *( s1 +1) *( s1 +4) ) ;
GH = syslin ( c ,g ) ;
GH1 = syslin ( c , g1 ) ;
nyquist ( GH ) ;
nyquist ( GH1 ) ;
// m t l b a x i s ( [ 1 . 5 0 . 2 0.3 0 . 3 ] ) ;
xtitle ( N y q u i s t p l o t o f ( 0 . 1 ( s +10) ( s +40) ) / ( s ( s +1)
( s +4) ) )
figure ;
show_margins ( GH , n y q u i s t )
disp ( s i n c e t h e p o i n t (1+%i0 ) i s e n c i r c l e d o n c e i n
c l o c k w i s e and o n c e i n a n t i c l o c k w i s e d i r e c t i o n by
N y q u i s t p l o t , s o N=0 and P=0 )
N =0; // no . o f e n c i r c l e m e n t o f 1+%i0 by G( s )H( s ) p l o t
anticlockwise
P =0; // no . o f p o l e s o f G( s )H( s ) w i t h p o s i t i v e r e a l
part
Z =P - N ; // np . o f z e r o s o f 1+G( s )H( s ) =0 w i t h p o s i t i v e
r e a l part
disp (Z , Z= )
disp ( a s Z=0 , t h e r e a r e no r o o t s o f c l o s e d l o o p
c h a r a c t e r s t i c s eq h a v i n g p o s i t i v e r e a l p a r t ,
hence system i s s t a b l e . )
224
225
226
// c a p t i o n : g a i n a n d p h a s e m a r g i n
// e x a m p l e 12 2 7
// p a g e 5 4 3
clf () ;
s = %s ;
s1 = - s ;
disp ( f o r K=0.5 )
g =(0.5) /( s *( s +1) ^2) ;
GH = syslin ( c ,g ) ;
nyquist ( GH ) ;
// m t l b a x i s ([ 5 1 500 5 0 0 ] ) ;
xtitle ( N y q u i s t p l o t o f ( 2 . 5 3 ) / ( s ( 0 . 4 s +1) ( 0 . 2 s
+1) ) )
pm = p_margin ( GH )
disp ( pm , p h a s e m a r g i n= )
gm = g_margin ( GH )
disp ( gm , g a i n m a r g i n= )
// c a p t i o n : d e t e r m i n e c l o s e l o o p s t a b i l i t y
// e x a m p l e 12 3 3
// p a g e 550
s = %s ;
g =(720*( s +1.25) ) /( s *( s +10) *( s ^2+2* s +9) ) ;
G = syslin ( c ,g )
fmin =0.1;
fmax =100;
bode (G , fmin , fmax )
[ gm , freqGM ]= g_margin ( G ) ;
[ pm , freqPM ]= p_margin ( G ) ;
227
228
show_margins ( G ) ;
disp ( gm , g a i n m a r g i n= ) ;
disp (( freqGM *2* %pi ) , g a i n m a r g i n f r e q= ) ;
disp ( pm , p h a s e m a r g i n= ) ;
disp (( freqPM *2* %pi ) , p h a s e m a r g i n f r e q= ) ;
show_margins ( G ) ;
disp ( s i n c e g a i n and p h a s e m a r g i n a r e b o t h n e g a t i v e
so system i s u n s t a b l e )
229
1 // c a p t i o n : r o o t l o c u s
2 // e x a m p l e 12 4 2
3 // p a g e 562
4 s = %s ;
5 syms K ;
6 GH = K /( s *( s +2) *( s +4) )
7 // s i n c e Mp=40%, s o .4= exp (( z e t a %pi ) / ( s q r t (1 z e t a
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2) )
zeta =0.3
// from g i v e n d a t a
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +2) *( s +4) ) + K
K = sym ( ( s 3+6 s 2+8 s ) )
d = diff (K , s )
e = -3* s ^2 -12* s -8
r1 = roots ( e )
disp ( r1 , r o o t s= )
disp ( 0.842 i s b r e a k away p o i n t s i n c i t l i e s on
root l o c u s )
CH = sym ( s 3+6 s 2+8 s+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( (48 K) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K=48 ) ;
K =48;
k =48
230
37 a =6* s ^2+48 // i n t e r s e c t i o n
o f root l o c u s with
imaginary plane
38 r = roots ( a )
39 g = k /( s *( s +2) *( s +4) )
40 G = syslin ( c ,g )
41 evans (g ,8)
42 xgrid (2)
43 disp ( t h e l i n e t h e t a=a c o s ( z e t a ) =72.5 i n t e r s e c t s
44
45
46
47
48
49
50
l o c u s a t s a =(0.5+ i 1 . 6 5 ) )
disp ( t h e v a l u e o f K a t s=s a i s f i n d t o be 1 4 . 8 7 f o r
Mp=40% )
K =14.87
ts =4/0.5
// t s =4/( z e t a wn )
Kv = limit ( s * GH ,s ,0)
Kv = eval ( Kv )
Kv = float ( Kv )
disp ( Kv , Kv= ) ;
root
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K
// e x a m p l e 1 2 . 4 3
// p a g e 564
s = %s ;
syms K ;
GH = K /( s *( s +2) *( s ^2+2* s +2) )
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +2) *( s ^2+2* s +2) ) + K
CH = sym ( s 4+4 s 3+6 s 2+4 s+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
231
232
14 c3 = coeffs ( CH , s ,3) ;
15 c4 = coeffs ( CH , s ,4) ;
16 b =[ c0 c1 c2 c3 c4 ]
17 routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
18 routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(1 ,3) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
routh =[ routh ;K ,0 ,0]
K = sym ( s 4+4 s 3+6 s 2+4 s )
d = diff (K , s )
e = -(4* s ^3+12* s ^2+12* s +4)
r = roots ( e )
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( ((20 4K) / 5 ) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K=5 ) ;
K =5;
k =5
a =5* s ^2+5 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s p l a n e
r = roots ( a )
disp (r , i n t e r s e c t i o n p o i n t w i t h i m a g i n a r y a x i s= )
g = k /( s *( s +2) *( s ^2+2* s +2) )
G = syslin ( c ,g )
evans (g ,200)
xgrid (2)
disp ( a n g l e o f d e p a r t u r e =90 and +90 )
disp ( breakaway p o i n t i s 1 and +j and j )
disp ( on s o l v i n g we f i n d K=1 )
233
234
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K
// e x a m p l e 1 2 . 4 4
// p a g e 565
s = %s ;
syms K ;
GH = K /(( s ^2+2* s +5) *( s ^2+2* s +2) )
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =(( s ^2+2* s +5) *( s ^2+2* s +2) ) + K
CH = sym ( ( ( s 2+2 s +5) ( s 2+2 s +2) )+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh
(1 ,3) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
routh =[ routh ;K ,0 ,0]
K = sym ( ( s 2+2 s +5) ( s 2+2 s +2) )
d = diff (K , s )
e = -(4* s ^3+12* s ^2+22* s +14)
r = roots ( e )
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( ( ( 7 . 5 1 4 4 (K+10) / 7 . 5 ) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K= 1 6 . 2 5 ) ;
K =16.25;
k =16.25
a =7.5* s ^2+26.25 // i n t e r s e c t i o n o f r o o t l o c u s w i t h s
235
36
37
38
39
40
41
plane
r = roots ( a )
g = k /(( s ^2+2* s +5) *( s ^2+2* s +2) )
G = syslin ( c ,g )
evans (g ,200)
xgrid (2)
disp (r , t h e p o i n t o f i n t e r s e c t i o n o f r o o t l o c u s w i t h
i m a g i n a r y a x i s = )
236
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K
// e x a m p l e 1 2 . 4 5
// p a g e 567
s = %s ;
syms K ;
GH = K *( s +1) /( s *( s +2) *( s ^2+4* s +8) )
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =(( s *( s +2) *( s ^2+4* s +8) ) ) + K *( s +1)
CH = sym ( ( ( s ( s +2) ( s 2+4 s +8) ) )+K ( s +1) ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
c4 = coeffs ( CH , s ,4) ;
b =[ c0 c1 c2 c3 c4 ]
routh =[ b ([5 ,3 ,1]) ; b ([4 ,2]) ,0]
routh =[ routh ; - det ( routh (1:2 ,1:2) ) / routh (2 ,1) , routh
(1 ,3) ,0]
routh (3 ,1) = simple ( routh (3 ,1) )
t = routh (2:3 ,1:2)
l = simple ( - det ( t ) / t (2 ,1) )
routh =[ routh ;l ,0 ,0]
routh =[ routh ;K ,0 ,0]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( (K2 28K1280)=0 ) ;
disp ( which g i v e s : ) ;
disp ( K=52.4 and 24.42 ) ;
K =52.4; // c o n s i d e r i n g p o s i t i v e v a l u e
k =52.4
a =((80 -52.4) /6) * s ^2+52.4 // i n t e r s e c t i o n o f r o o t l o c u s
with imaginary a x i s
r = roots ( a )
g = k *( s +1) /( s *( s +2) *( s ^2+4* s +8) )
G = syslin ( c ,g )
clf () ;
evans (g ,10)
237
xgrid (2)
disp (r , t h e p o i n t o f i n t e r s e c t i o n o f r o o t l o c u s w i t h
i m a g i n a r y a x i s = )
238
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
240
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// from g i v e n d a t a
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s *( s +2) *( s +4) ) + K
K = sym ( ( s 3+6 s 2+8 s ) )
d = diff (K , s )
e = -3* s ^2 -12* s -8
r1 = roots ( e )
disp ( r1 , r o o t s= )
disp ( 0.85 i s b r e a k away p o i n t s i n c i t l i e s on r o o t
l o c u s )
CH = sym ( s 3+6 s 2+8 s+K ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
c0 = coeffs ( CH , s ,0) ;
c1 = coeffs ( CH , s ,1) ;
c2 = coeffs ( CH , s ,2) ;
c3 = coeffs ( CH , s ,3) ;
b =[ c0 c1 c2 c3 ]
n =4;
routh =[ b ([4 ,2]) ; b ([3 ,1]) ];
routh =[ routh ; - det ( routh ) / routh (2 ,1) ,0]
t = routh (2:3 ,1:2)
routh =[ routh ; - det ( t ) / t (2 ,1) ,0]
disp ( routh , r o u t h= )
disp ( f o r g i v e n s y s t e m t o be m a r g i n a l l y s t a b l e : ) ;
disp ( (48 K) =0 ) ;
disp ( which g i v e s : ) ;
disp ( K=48 ) ;
K =48;
k =48
a =6* s ^2+48 // i n t e r s e c t i o n o f r o o t l o c u s w i t h
imaginary plane
r = roots ( a )
g = k /( s *( s +2) *( s +4) )
G = syslin ( c ,g )
evans (g ,8)
xgrid (2)
disp ( t h e l i n e t h e t a=a c o s ( z e t a ) =73.9 i n t e r s e c t s r o o t
l o c u s a t s a =(0.5+ i 1 . 6 6 ) )
241
disp ( t h e v a l u e o f K a t s=s a i s f i n d t o be 15 f o r
z e t a =0.277 )
K =15
k =15
disp (r , t h e p o i n t o f i n t e r s e c t i o n o f r o o t l o c u s w i t h
i m a g i n a r y a x i s = )
g = k /( s *( s +2) *( s +4) )
cl = g /(1+ g )
disp ( cl , C( s ) /R( s )= )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// c a p t i o n : r o o t l o c u s a n d v a l u e o f K
// e x a m p l e 1 2 . 4 9
// p a g e 576
s = %s ;
syms K ;
GH =( K *( s +4) ) /( s +2) ^2
disp ( t h e c h a r a c t e r s t i c s eq . i s d e t e r m i n e d a s : )
CH =( s +2) ^2+( K *( s +4) )
CH = sym ( ( ( s +2) 2 )+K ( s +4) ) ;
disp ( =0 ,CH , c h a r a c t e r s t i c s e q , CH= )
K = sym ( ( ( s +2) 2 / ( s +4) ) )
d = diff (K , s )
e =( s +2) *( s +6)
r1 = roots ( e )
disp ( r1 , r o o t s= )
disp ( 2 and 6 i s b r e a k away p o i n t )
g =( s +4) /(( s +2) ^2)
G = syslin ( c ,g )
clf () ;
evans (g ,10)
xgrid (2)
disp ( f o r wd=2 r a d / s e c , t h e p o i n t on r o o t l o c u s i s s
=4+j 2 )
disp ( t h e v a l u e o f K a t s=4+j 2 i s 4 )
K =4
k =4
g = k *( s +4) /(( s +2) ^2)
cl = g /(1+ g )
disp ( cl , C( s ) /R( s )= )
Scilab code Exa 12.50 Root Locus and Closed loop Transfer Function
1
// c a p t i o n :
243
244
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
disp ( p a r t b )
g = K /( s +4)
h =1/ s
gh = g * h
CL = g /(1+ gh )
disp ( CL , C( s ) /R( s )= )
Scilab code Exa 12.51 Root Locus and Gain and Phase Margin
1 // c a p t i o n : r o o t l o c u s a n d g a i n , p h a s e m a r g i n
2 // e x a m p l e 1 2 . 5 1
3 // p a g e 580
4 s = %s ;
245
246
5
6
7
8
9
10
11
12
13
K =3.46
G = K /( s *( s +1) *( s +2) )
G = syslin ( c ,G )
clf () ;
evans (G ,20)
xgrid (2)
[ gm , freq_gm ]= g_margin ( G )
[ pm , freq_pm ]= p_margin ( G )
disp ( gm , g a i n m a r g i n= , freq_gm *2* %pi ,
g a i n m a r g i n f r e q= )
14 disp ( pm , p h a s e m a r g i n= , freq_pm *2* %pi ,
p h a s e m a r g i n f r e q= )
// c a p t i o n : o b t a i n s t a t e m a t r i x
// e x a m p l e 12 5 4
// p a g e 583
s = %s ;
g =5*( s +2) /( s *( s +1) *( s +5) ) ;
CL = syslin ( c ,g ) ;
disp ( CL , C( s ) /R( s )= ) ;
SS = tf2ss ( CL )
[ Ac , Bc ,U , ind ]= canon ( SS (2) , SS (3) )
disp ( SS , s t a t e s p a c e m a t r i x= )
disp ( Ac , Ac ,Bc , Bc ,U , U ,ind , i n d )
247
5
6
7
8
9
10
11
// c a p t i o n : o b t a i n s t a t e t r a n s i s t i o n m a t r i x
// e x a m p l e 12 5 6
// p a g e 586
s = %s ;
syms t
A =[0 1;0 -3]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
// f o r c a l c u l a t i n g s t a t e t r a n s i s t i o n m a t r i x
ip =[0 0;0 0]
i =1;
j =1;
for i =1:2
for j =1:2
if ( i ==2 & j ==1)
else
ip (i , j ) = ilaplace ( r (i , j ) ,s , t ) ;
j = j +1;
end
end
i = i +1;
end
r (2 ,1) =0
248
26
disp ( ip , s t a t e t r a n s i s t i o n m a t r i x , i p ( t )= ) ;
// c a p t i o n : o b t a i n t i m e r e s p o n s e
// e x a m p l e 12 5 7
// p a g e 586
s = %s ;
syms t
A =[0 1; -2 -3]
B =[1 0]
x0 =[0 0]
u =1/( s +1)
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
m = r * B *(1/( s +1) ) ;
// f o r c a l c u l a t i n g z e r o s t a t e r e s p o n s e
x =[0;0]
x (1 ,1) = ilaplace ( m (1 ,1) ,s , t ) ;
x (2 ,1) = ilaplace ( m (2 ,1) ,s , t ) ;
disp (x , t i m e r e s p o n s e o f t h e system , x ( t )= ) ;
249
8
9
10
11
12
13
14
15
16
17
18
19
20
x0 =[1 0]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
m = r * B *(1/ s )
r1 = r * x0
X = r1 + m
// f o r c a l c u l a t i n g z e r o s t a t e r e s p o n s e
x =[0;0]
x (1 ,1) = ilaplace ( X (1 ,1) ,s , t ) ;
x (2 ,1) = ilaplace ( X (2 ,1) ,s , t ) ;
disp (x , z e r o i n p u t r e s p o n s e o f t h e system , x ( t )= ) ;
// c a p t i o n : o b t a i n t r a n s f e r m a t r i x
// e x a m p l e 12 6 1
// p a g e 592
s = %s ;
syms t
A =[ -1 -1;3 -5]
B =[1 1]
C =[1 2]
[ r c ]= size ( A ) ; // s i z e o f m a t r i x A
p = s * eye (r , c ) -A ; // s IA where I i s i d e n t i t y m a t r i x
q = det ( p ) // d e t e r m i n a n t o f s I A
r = inv ( p ) // i n v e r s e o f s I A
G=C*r*B
disp (G , t r a n s f e r m a t r i x= )
250
Appendix
Scilab code AP 1 SERIES OF TWO FUNCTION
1 function [ y ] = series ( sys1 , sys2 )
2 y =
sys1 * sys2
3 endfunction
251