Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
219 views

Control Systems Applications in Scilab

This document provides Scilab code for control systems theory and applications. It contains code organized by chapter that corresponds to concepts in the textbook "Control Systems" by Smarajit Ghosh. The code covers topics such as Laplace transforms, transfer functions, feedback characteristics, stability analysis using root locus and frequency response methods. There are over 50 code files provided as supplements to explain control systems engineering concepts.

Uploaded by

adrian.petrovan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
219 views

Control Systems Applications in Scilab

This document provides Scilab code for control systems theory and applications. It contains code organized by chapter that corresponds to concepts in the textbook "Control Systems" by Smarajit Ghosh. The code covers topics such as Laplace transforms, transfer functions, feedback characteristics, stability analysis using root locus and frequency response methods. There are over 50 code files provided as supplements to explain control systems engineering concepts.

Uploaded by

adrian.petrovan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 124

Scilab Code for

Control Systems
Theory and Applications
by Smarajit Ghosh1

Created by
Anuradha Singhania
4th Year Student
B. Tech. (Elec. & Commun. )
Sri Mata Vaishno Devi University, Jammu

College Teacher
Prof. Amit Kumar Garg
Sri Mata Vaishno Devi University, Jammu
Reviewer
Prof. Madhu Belur, IIT Bombay

29 June 2010

1 Funded by a grant from the National Mission on Education through ICT,


http://spoken-tutorial.org/NMEICT-Intro
Book Details

Authors: Smarajit Ghosh

Title: Control Systems

Publisher: Pearson Education

Edition: 2nd

Year: 2009

Place: New Delhi

ISBN: 978-81-317-0828-6

1
Contents

List of Scilab Code 4

2 Laplace Transform and Matrix Algebra 11


2.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3 Transfer Function 14
3.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4 Control system Components 17


4.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

6 Control system Components 21


6.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

8 Time Domain Analysis of Control Systems 29


8.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

9 Feedback Characteristics of control Systems 44


9.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

10 Stability 54
10.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

11 Root Locus Method 64


11.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

12 Frequency Domain Analysis 90


12.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

2
13 Bode Plot 95
13.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

15 Nyquist Plot 103


15.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

17 State Variable Approach 112


17.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

18 Digital Control Systems 122


18.1 Scilab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

3
List of Scilab Code

2.01-01 2.01.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.01-02 2.01.02sci . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.01-03 2.01.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.03 2.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.04 2.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.05-01 2.05.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.05-02 2.05.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.06 2.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.11 2.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.13 2.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.02 3.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.03 3.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.04 3.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.15 3.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.16 3.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.17 3.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.18 3.18.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.19 3.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.23 3.23.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.01 4.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.02 4.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.03 4.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.04 4.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.05 4.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
F1 parallel.sce . . . . . . . . . . . . . . . . . . . . . . . . . 21
F2 serial.sce . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.01 6.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.02 6.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4
6.03 6.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.04 6.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.05 6.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.06 6.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.07 6.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.08 6.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.09 6.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.10 6.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.11 6.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.12 6.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.13 6.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.14 6.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.15 6.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.02 8.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
8.03-01 8.03.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 29
8.03-02 8.03.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 30
8.03-03 8.03.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 30
8.04 8.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
8.05 8.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
8.06 8.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
8.07 8.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
8.08 8.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8.09 8.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
8.10 8.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
8.11 8.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
8.12 8.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
8.13 8.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.14 8.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.15 8.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.16 8.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.17 8.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.19 8.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.20 8.20.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.23-01 8.23.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.23-02 8.23.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.23-03 8.23.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.23-04 8.23.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.24 8.24.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

5
8.32 8.32.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
9.01 9.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.02 9.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.03 9.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.04 9.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
9.05 9.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
9.06 9.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
9.07 9.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.08 9.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
9.09 9.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9.10 9.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
9.11 9.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10.02-01 10.02.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 54
10.02-02 10.02.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . 54
10.02-03 10.02.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.03 10.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.04 10.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.05-01 10.05.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.05-02 10.05.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.06 10.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.07 10.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
10.08 10.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
10.09 10.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
10.10 10.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10.11 10.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.12 10.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.13 10.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
10.14 10.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
10.15 10.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
10.16 10.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
11.01 11.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
11.02 11.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
11.03 11.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
11.04 11.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
11.05 11.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
11.06 11.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
11.08 11.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
11.09 11.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

6
11.10 11.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
11.11 11.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
11.12 11.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
11.13 11.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
11.14 11.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
11.15 11.15.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
11.16 11.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
11.17 11.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
11.19 11.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
11.20 11.20.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
11.21 11.21.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
11.22 11.22.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
11.23 11.23.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
11.25 11.25.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
11.26 11.26.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
11.27 11.27.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
11.28 11.28.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
12.01 12.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
12.02 12.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
12.03 12.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
12.04 12.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
12.05 12.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
13.01 13.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.02 13.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.03 13.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
13.04 13.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.05 13.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.06 13.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
15.01 15.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
15.02 15.02.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
15.03 15.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
15.04 15.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
15.05 15.05.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
15.06 15.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
15.07 15.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
15.08 15.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
17.03 17.03.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
17.04 17.04.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

7
17.06 17.06.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
17.07 17.07.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
17.08 17.08.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
17.09 17.09.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
17.10 17.10.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
17.11 17.11.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
17.12 17.12.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
17.13 17.13.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
17.14 17.14.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
17.16 17.16.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
17.17 17.17.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
17.18 17.18.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
17.19 17.19.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
17.20 17.20.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
17.21 17.21.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
17.22 17.22.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
17.23 17.23.sci . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
F3 ztransfer.sce . . . . . . . . . . . . . . . . . . . . . . . . . 122
18.01 18.01.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 122
18.08 18.08.01.sci . . . . . . . . . . . . . . . . . . . . . . . . . 122

8
List of Figures

11.1 Output Graph of S 11.01 . . . . . . . . . . . . . . . . . . . . 65


11.2 Output Graph of S 11.02 . . . . . . . . . . . . . . . . . . . . 66
11.3 Output Graph of S 11.03 . . . . . . . . . . . . . . . . . . . . 67
11.4 Output of S 11.04 . . . . . . . . . . . . . . . . . . . . . . . . 68
11.5 Output of S 11.05 . . . . . . . . . . . . . . . . . . . . . . . . 69
11.6 Output of S 11.06 . . . . . . . . . . . . . . . . . . . . . . . . 70
11.7 Output of S 11.08 . . . . . . . . . . . . . . . . . . . . . . . . 71
11.8 Output of S 11.09 . . . . . . . . . . . . . . . . . . . . . . . . 72
11.9 Output of S 11.13 . . . . . . . . . . . . . . . . . . . . . . . . 75
11.10Output of S 11.14 . . . . . . . . . . . . . . . . . . . . . . . . 76
11.11Output of S 11.15 . . . . . . . . . . . . . . . . . . . . . . . . 77
11.12Output of S 11.16 . . . . . . . . . . . . . . . . . . . . . . . . 78
11.13Output of S 11.17 . . . . . . . . . . . . . . . . . . . . . . . . 79
11.14Output of S 11.19 . . . . . . . . . . . . . . . . . . . . . . . . 80
11.15Output of S 11.20 . . . . . . . . . . . . . . . . . . . . . . . . 81
11.16Output of S 11.21 . . . . . . . . . . . . . . . . . . . . . . . . 82
11.17Output of S 11.22 . . . . . . . . . . . . . . . . . . . . . . . . 83
11.18Output of S 11.23 . . . . . . . . . . . . . . . . . . . . . . . . 84
11.19Output of S 11.25 . . . . . . . . . . . . . . . . . . . . . . . . 85
11.20Output of S 11.26 . . . . . . . . . . . . . . . . . . . . . . . . 86
11.21Output of S 11.27 . . . . . . . . . . . . . . . . . . . . . . . . 88
11.22Output of S 11.28 . . . . . . . . . . . . . . . . . . . . . . . . 89

13.1 Output of S 13.01 . . . . . . . . . . . . . . . . . . . . . . . . 96


13.2 Output of S 13.02 . . . . . . . . . . . . . . . . . . . . . . . . 97
13.3 Output of S 13.03 . . . . . . . . . . . . . . . . . . . . . . . . 99
13.4 Output of S 13.04 . . . . . . . . . . . . . . . . . . . . . . . . 100
13.5 Output of S 13.05 . . . . . . . . . . . . . . . . . . . . . . . . 101
13.6 Output of S 13.06 . . . . . . . . . . . . . . . . . . . . . . . . 102

9
15.1 Output of S 15.01 . . . . . . . . . . . . . . . . . . . . . . . . 104
15.2 Output of S 15.02 . . . . . . . . . . . . . . . . . . . . . . . . 105
15.3 Output of S 15.03 . . . . . . . . . . . . . . . . . . . . . . . . 106
15.4 Output of S 15.04 . . . . . . . . . . . . . . . . . . . . . . . . 107
15.5 Output of S 15.05 . . . . . . . . . . . . . . . . . . . . . . . . 108
15.6 Output of S 15.06 . . . . . . . . . . . . . . . . . . . . . . . . 109
15.7 Output of S 15.07 . . . . . . . . . . . . . . . . . . . . . . . . 110
15.8 Output of S 15.08 . . . . . . . . . . . . . . . . . . . . . . . . 111

10
Chapter 2

Laplace Transform and Matrix


Algebra

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox.

2.1 Scilab Code


Example 2.01-01 2.01.01.sci

1 syms t s ;
2 y=l a p l a c e ( ’ 13 ’ , t , s ) ;
3 disp ( y , ” ans=” )

Example 2.01-02 2.01.02sci

1 syms t s ;
2 y=l a p l a c e ( ’ 4+5∗%eˆ(−3∗ t ) ’ , t , s ) ;
3 disp ( y , ” ans=” )

Example 2.01-03 2.01.03.sci

1 syms t s ;
2 y=l a p l a c e ( ’ 2∗ t −3∗%eˆ(− t ) ’ , t , s ) ;
3 disp ( y , ” ans=” )

11
Example 2.03 2.03.sci

1 p=poly ( [ 9 1 ] , ’ s ’ , ’ c o e f f ’ )
2 q=poly ( [ 3 7 1 ] , ’ s ’ , ’ c o e f f ’ )
3 f=p/q ;
4 disp ( f , ”F( s )=” )
5 x=s ∗ f ;
6 y=l i m i t ( x , s , 0 ) ; / / f i n a l v a l u e theorem
7 disp ( y , ” f ( i n f )=” )
8 z=l i m i t ( x , s , %inf ) ; / / i n i t i a l value theorem
9 disp ( z , ” f ( 0 )=” )

Example 2.04 2.04.sci

1 s=%s
2 syms t ;
3 disp ( ( s +3) / ( ( s +1) ∗( s +2) ∗( s +4) ) , ”F( s )=” )
4 [A]= pfss ( ( s +3) / ( ( s +1) ∗( s +2) ∗( s +4) ) ) / / p a r t i a l fraction
of F( s )
5 F1= i l a p l a c e (A( 1 ) , s , t )
6 F2= i l a p l a c e (A( 2 ) , s , t )
7 F3= i l a p l a c e (A( 3 ) , s , t )
8 F=F1+F2+F3 ;
9 disp (F , ” f ( t )=” )

Example 2.05-01 2.05.01.sci

1 syms t s ;
2 y= l a p l a c e ( ’%eˆ(− t ) +5∗ t +6∗%eˆ(−3∗ t ) ’ , t , s ) ;
3 disp ( y , ” ans=” )

Example 2.05-02 2.05.02.sci

1 syms t s ;
2 y=l a p l a c e ( ’ 5+6∗ t ˆ2+3∗%eˆ(−2∗ t ) ’ , t , s ) ;
3 disp ( y , ” ans=” )

12
Example 2.06 2.06.sci

1 syms t s ;
2 y=l a p l a c e ( ’3− %eˆ(−3∗ t ) ’ , t , s ) ;
3 disp ( y , ” ans=” )

Example 2.11 2.11.sci

1 p=poly ( [ 0 . 3 8 ] , ’ s ’ , ’ c o e f f ’ ) ;
2 q=poly ( [ 0 0 . 5 4 3 2 . 4 8 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 F=p/q ;
4

5 syms s ;
6 x=s ∗F ;
7 y=l i m i t ( x , s , 0 ) ; / / final value theorem
8 y=db l ( y ) ;
9 disp ( y , ” f ( i n f )=” )
10 z=l i m i t ( x , s , %inf ) / / // i n i t i a l value theorem
11 z=db l ( z ) ;
12 disp ( z , ” f ( 0 )=” )

Example 2.13 2.13.sci

1 s=%s ;
2 p=poly ( [ 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 q=poly ( [ 0 −1 −1 −2] , ’ s ’ , ’ r o o t s ’ ) ;
4 f=p/q ;
5 syms t s ;
6 y=i l a p l a c e ( f , s , t ) ;
7 disp ( y , ” f ( t )=” )

13
Chapter 3

Transfer Function

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox.

3.1 Scilab Code


Example 3.02 3.02.sci

1 syms t s ;
2 f=%eˆ(−3∗ t ) ;
3 y=l a p l a c e ( ’%eˆ(−3∗ t ) ’ , t , s ) ;
4 disp ( y , ”G( s )=” )

Example 3.03 3.03.sci

1 syms t s ;
2 disp (%eˆ(−3∗ t ) , ”g ( t )=” ) ;
3 y1=l a p l a c e ( ’%eˆ(−3∗ t ) ’ , t , s ) ;
4 disp ( y1 , ”G( s )=” )
5 disp (%eˆ(−4∗ t ) , ” r ( t )=” ) ;
6 y2=l a p l a c e ( ’%eˆ(−4∗ t ) ’ , t , s ) ;
7 disp ( y2 , ”R( s )=” )
8 disp ( y1∗y2 , ”G( s )R( s )=” )

Example 3.04 3.04.sci

14
1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( 4 ∗ ( s +2) ∗ ( ( s +2.5) ˆ 3) ) / ( ( s +6) ∗ ( ( s +4) ˆ2 ) ) ) ;
3 plzr (H)

Example 3.15 3.15.sci

1 syms t s
2 y=l a p l a c e (%eˆ(−3∗ t ) ∗ sin (2∗ t ) , t , s ) ;
3 disp ( y , ” ans=” )

Example 3.16 3.16.sci

1 syms t s ;
2 x=6−4∗%eˆ(−5∗ t ) /5+%eˆ(−3∗ t ) // Given step Response of
the system
3 printf ( ” Derivative of step response g i v e s impulse
r e s p o n s e \n” )
4 y=d i f f ( x , t ) ; // D e r i v a t i v e of step response
5 p r i n t f ( ” L a p l a c e Transform o f Impulse Response g i v e s th e
T r a n s f e r Function \n ” )
6 p=l a p l a c e ( y , t , s ) ;
7 disp ( p , ” T r a n s f e r Function=” )

Example 3.17 3.17.sci

1 p r i n t f ( ” Given : P o l e s a r e s=−1,(−2+ i ) ,(−2− i ) ; z e r o s s


=−3+i ,−3− i , Gain f a c t o r ( k )=5 \n” )
2 num=poly([−3+%i,−3−%i ] , ’ s ’ , ’ r o o t s ’ ) ;
3 den=poly([−1,−2+%i,−2−%i ] , ’ s ’ , ’ r o o t s ’ ) ;
4 G=(5∗num) / den ;
5 disp (G, ”G( s )=” )

Example 3.18 3.18.sci

1 s=%s ;
2 G=s y s l i n ( ’ c ’ , ( 5 ∗ ( s +2) ) / ( ( s +3) ∗( s +4) ) ) ;
3 disp (G, ”G( s )=” )

15
4 x=denom(G) ;
5 disp ( x , ” C h a r a c t e r i s t i c s Polynomial=” )
6 y=roots ( x ) ;
7 disp ( y , ” P o l e s o f a system=” )

Example 3.19 3.19.sci

1 p r i n t f ( ” Given : P o l e s a r e s =−3, Z e r o s a r e s =−2, Gain


F a c t o r ( k )=5 \n ” )
2 num=poly ( [ − 2 ] , ’ s ’ , ’ r o o t s ’ ) ;
3 den=poly ( [ − 3 ] , ’ s ’ , ’ r o o t s ’ ) ;
4 G=5∗num/ den ;
5 disp (G, ”G( s )=” )
6 disp ( ” Input i s Step Function ” )
7 syms t s ;
8 R=l a p l a c e ( 1 , t , s ) ;
9 disp (R, ”R( s )=” )
10 p r i n t f ( ”C( s )=R( s )G( s ) \n” )
11 C=R∗G;
12 disp (C, ”C( s )=” )
13 c=i l a p l a c e (C, s , t ) ;
14 disp ( c , ” c ( t )=” )

Example 3.23 3.23.sci

1 // p o l e zero plot for g ( s ) =( s ˆ2+3 s +2) / ( s ˆ2+7 s + 1 2 )


2 s=%s ;
3 p=poly ( [ 2 3 1 ] , ’ s ’ , ” c o e f f ” )
4 q=poly ( [ 1 2 7 1 ] , ’ s ’ , ” c o e f f ” )
5 V=s y s l i n ( ’ c ’ , p , q )
6 plzr (V)
7 syms s t ;
8 v =i l a p l a c e ( ’ (2+(3∗ s )+s ˆ 2) / ( s ˆ2+(7∗ s ) +12) ’ , s , t )
9 disp ( v , ”V( t ) = ’)

16
Chapter 4

Control system Components

4.1 Scilab Code


Example 4.01 4.01.sci

1 p r i n t f ( ” Given a ) E x c i t a t i o n v o l t a g e ( Ein )=2V \n b )


S e t t i n g Ratio ( a )= 0 . 4 \n” )
2 Ein =2;
3 disp ( Ein , ” Ein=” )
4 a =0.4;
5 disp ( a , ”a=” )
6 Rt =10ˆ3;
7 disp ( Rt , ”Rt=” )
8 Rl =5∗10ˆ3;
9 disp ( Rl , ” Rl=” )
10 p r i n t f ( ”Eo = ( a∗ Ein ) /(1+( a∗(1−a ) ∗Rt ) / Rl ) \n” )
11 Eo = ( a∗ Ein ) /(1+( a∗(1−a ) ∗Rt ) / Rl ) ;
12 disp ( Eo , ” output v o l t a g e ( E0 )=” )
13 p r i n t f ( ” e =(( a ˆ 2 ) ∗(1−a ) ) / ( ( a∗(1−a ) ) +(Rl /Rt ) ) \n” )
14 e =(( a ˆ 2) ∗(1−a ) ) / ( ( a∗(1−a ) ) +(Rl /Rt ) ) ;
15 disp ( e , ” l o a d i n g e r r o r=” )
16 p r i n t f ( ”E=Ein ∗ e \n” )
17 E=Ein ∗ e ; / / V o l t a g e e r r o r = E x c i t a t i o n v o l t a g e ( E i n ) ∗
Loading error ( e )
18 disp (E , ” V o l t a g e e r r o r=” )

17
Example 4.02 4.02.sci

1 p r i n t f ( ”n=5 , H e l i c a l turn \n” )


2 n=5; / / H e l i c a l t u r n
3 disp ( n , ”n=” )
4 p r i n t f ( ”N=9000 , Winding Turn \n” )
5 N=9000; / / W i n d i n g T u r n
6 disp (N, ”N=” )
7 p r i n t f ( ”R=10000 , P o t e n t i o m e t e r R e s i s t a n c e \n” )
8 R=10000; / / P o t e n t i o m e t e r R e s i s t a n c e
9 disp (R, ”R=” )
10 p r i n t f ( ” Ein=90 , Input v o l t a g e \n” )
11 Ein =90; / / I n p u t v o l t a g e
12 disp ( Ein , ” Ein=” )
13 p r i n t f ( ” r =5050 , R e s i s t a n c e a t mid p o i n t \n” )
14 r =5050; / / R e s i s t a n c e a t m i d p o i n t
15 disp ( r , ” r=” )
16 p r i n t f ( ”D=r −5000 , D e v i a t i o n from nominal a t mid−p o i n t \
n” )
17 D=r −5000; / / D e v i a t i o n f r o m n o m i n a l a t m i d − p o i n t
18 disp (D, ”D=” )
19 p r i n t f ( ”L=D/R∗100 , L i n e a r i t y \n” )
20 L=D/R∗ 1 0 0 ; / / L i n e a r i t y
21 disp (L , ”L=” )
22 p r i n t f ( ”R=Ein /N , R e s o l u t i o n \n” )
23 R=Ein /N; / / R e s o l u t i o n
24 disp (R, ”R=” )
25 p r i n t f ( ”Kp=Ein /(2∗ p i ∗n ) , P o t e n t i o m e t e r Constant \n” )
26 Kp=Ein /(2∗ %pi∗n ) ; / / P o t e n t i o m e t e r C o n s t a n t
27 disp (Kp, ”Kp=” )

Example 4.03 4.03.sci

1 p r i n t f ( ” s i n c e S2 i s t h e r e f e r a n c e s t a t o r winding , Es2=
KVcos0 \n where Es2 & Er a r e rms v o l t a g e s \n ’ )
2 k=1
3 Theta =60;
4 d i s p ( Theta , ” Theta=” )

18
5 V=28;
6 d i s p (V, ”V( a p p l i e d )=” )
7 p r i n t f ( ” Es2=V∗ cos ( Theta ) \n” )
8 Es2=k∗V∗ c o s ( Theta ∗( %pi /180) ) ;
9 d i s p ( Es2 , ” Es2=” )
10 p r i n t f ( ” Es1=k∗V∗ cos ( Theta −120)\n” )
11 Es1=k∗V∗ c o s ( ( Theta −120) ∗( %pi /180) ) ; // Given Theta=60
in degrees
12 d i s p ( Es1 , ” Es1= ’ )
13 p r i n t f ( ” Es3=k∗V∗ c o s ( Theta +120) \n ” )
14 Es3=k∗V∗ c o s ( ( Theta +120) ∗( %pi /180) ) ;
15 d i s p ( Es3 , ” Es3= ’ )
16 p r i n t f ( ” Es31=s q r t ( 3 ) ∗k∗Er∗ s i n ( Theta ) ” )
17 Es31=sqrt ( 3 ) ∗k∗V∗ sin ( Theta ∗( %pi /180) ) ;
18 disp ( Es31 , ” Es31 = ’)
19 p r i n t f ( ” Es12=sqrt ( 3 ) ∗k∗Er∗ sin ( ( Theta −120) ” )
20 Es12=s q r t ( 3 ) ∗k∗V∗ s i n ( ( Theta −120) ∗( %pi /180) ) ;
21 d i s p ( Es12 , ” Es12= ’ )
22 p r i n t f ( ” Es23=s q r t ( 3 ) ∗k∗Er∗ s i n ( ( Theta +120) ” )
23 Es23=s q r t ( 3 ) ∗k∗V∗ s i n ( ( Theta +120) ∗( %pi /180) ) ;
24 d i s p ( Es23 , ” Es23= ’ )

Example 4.04 4.04.sci

1 p r i n t f ( ” S e n s i t i v i t y =5v /1000rpm \n” )


2 Vg=5;
3 disp (Vg , ”Vg=” )
4 p r i n t f ( ”w( i n r a d i a n s / s e c ) =(1000/60) ∗2∗ p i \n” )
5 w=(1000/60) ∗2∗ %pi ;
6 disp (w, ”w=” )
7 p r i n t f ( ”Kt=Vg/w \n ’ )
8 Kt=Vg/w;
9 d i s p ( Kt , ” Gain c o n s t a n t ( Kt )=” )

Example 4.05 4.05.sci

1 p r i n t f ( ” Torque=KmVm=2 \n” )
2 t =2;

19
3 disp ( t , ” Torque ( t )=” )
4 Fm= 0 . 2 ;
5 disp (Fm, ” C o e f f i c i e n t o f V i s c o u s f r i c t i o n (Fm)=” )
6 N=4
7 I =0.2
8 F1=0.05
9 p r i n t f ( ”Wnl=t /Fm” )
10 Wnl=t /Fm;
11 disp (Wnl , ”No Load Speed (Wnl)=” )
12 p r i n t f ( ”Fwt=I +(Nˆ2∗F1 ) \n” )
13 Fwt=I +(Nˆ2∗F1 ) ;
14 disp ( Fwt , ” Total V i s c o u s F r i c t i o n ( Fwt )=” )
15 p r i n t f ( ”Te=t −(Fwt∗w) \n” )
16 Te=0.8 / / l o a d
17 w=(t−Te ) /Fwt ;
18 disp (w, ” Speed o f Motor (w)=” )

20
Chapter 6

Control system Components

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox.
To Run the following codes use the same destination for the function as
well as the main code.

6.1 Scilab Code


Example F1 parallel.sce

1 function [ y]= p a r a l l e l ( sys1 , s y s 2 )


2 y=s y s 1+s y s 2
3 endfunction

Example F2 serial.sce

1 function [ y]= s e r i e s ( sys1 , s y s 2 )


2 y=s y s 1 ∗ s y s 2
3

4 endfunction

Example 6.01 6.01.sci

1 exec s e r i e s . s c e ;
2 s=%s ;

21
3 s y s 1=s y s l i n ( ’ c ’ , ( s +3) / ( s +1) )
4 s y s 2=s y s l i n ( ’ c ’ , 0 . 2 / ( s +2) )
5 s y s 3=s y s l i n ( ’ c ’ , 5 0 / ( s +4) )
6 s y s 4=s y s l i n ( ’ c ’ , 1 0 / ( s ) )
7 a=s e r i e s ( sys1 , s y s 2 ) ;
8 b=s e r i e s ( a , s y s 3 ) ;
9 y=s e r i e s ( b , s y s 4 ) ;
10 y=simp ( y ) ;
11 disp ( y , ”C( s ) /R( s )=” )

This code requires S F1.

Example 6.02 6.02.sci

1 exec p a r a l l e l . s c e ;
2 s=%s ;
3 s y s 1=s y s l i n ( ’ c ’ , 1 / s )
4 s y s 2=s y s l i n ( ’ c ’ , 2 / ( s +1) )
5 s y s 3=s y s l i n ( ’ c ’ , 3 / ( s +3) )
6 a=p a r a l l e l ( sys1 , s y s 2 ) ;
7 y=p a r a l l e l ( a , s y s 3 ) ;
8 y=simp ( y ) ;
9 disp ( y , ”C( s ) /R( s )=” )

This code requires S F2.

Example 6.03 6.03.sci

1 exec s e r i e s . s c e ;
2 s=%s ;
3 s y s 1=s y s l i n ( ’ c ’ , 3 / ( s ∗( s +1) ) )
4 s y s 2=s y s l i n ( ’ c ’ , s ˆ 2 / ( 3 ∗ ( s +1) ) )
5 s y s 3=s y s l i n ( ’ c ’ , 6 / ( s ) )
6 a=(−1)∗ s y s 3 ;
7 b=s e r i e s ( sys1 , s y s 2 ) ;
8 y=b / . a // f e e d b a c k operation
9 y=simp ( y )
10 disp ( y , ”C( s ) /R( s )=” )

22
Example 6.04 6.04.sci

1 exec p a r a l l e l . s c e ;
2 syms G1 G2 G3 H;
3 a=s e r i e s (G1 , G2) ;
4 b=p a r a l l e l ( a , G3) ;
5 y=b / .H / / n e g a t i v e f e e d b a c k operation
6 y=s i m p l e ( y )
7 disp ( y , ”C( s ) /R( s )=” )

Example 6.05 6.05.sci

1 exec s e r i e s . s c e ;
2 syms G1 G2 H1 H2 s ;
3 a=G1 / . H1 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
4 b=a / . H2 ; / / n e g a t i v e f e e d b a c k o p e r a t i o n
5 y=s e r i e s ( b , G2) ;
6 y=s i m p l e ( y ) ;
7 disp ( y , ”C( s ) /R( s )=” )

Example 6.06 6.06.sci

1 exec p a r a l l e l . s c e ;
2 exec s e r i e s . s c e ;
3 syms G1 G2 G3 G4 G5 G6 H1 H2 ;
4 a=p a r a l l e l (G3 , G5) ;
5 b=p a r a l l e l ( a,−G4) ;
6 c=s e r i e s (G1 , G2) ;
7 d=c / . H1 ;
8 e=s e r i e s ( b , d ) ;
9 f=e / . H2 ;
10 y=s e r i e s ( f , G6) ;
11 y=s i m p l e ( y ) ;
12 disp ( y , ”C( s ) /R( s )=” )

Example 6.07 6.07.sci

23
1 exec s e r i e s . s c e ;
2 syms G1 G2 G3 H1 H2 R X;
3 // p u t t i n g x =0 , t h e n solving the block
4 a=G3 / . H1 ;
5 b=s e r i e s (G1 , G2) ;
6 c=s e r i e s ( a , b ) ;
7 x1=c / . H2 ;
8 C1=R∗x1 ;
9 disp ( x1 , ”C1( s ) /R( s )=” )
10 // p u t t i n g r =0 , then solving the block
11 d=s e r i e s (G1 , G2) ;
12 e=s e r i e s ( d , H2) ;
13 f=G3 / . H1 ;
14 x2=f / . e ;
15 C2=X∗x2 ;
16 disp ( x2 , ”C2( s ) /X( s )=” )
17 // r e s u l t a n t output C= C 1 + C 2
18 C=C1+C2 ;
19 C=s i m p l e (C) ;
20 disp (C, ” R e s u l t a n t Output=” )

Example 6.08 6.08.sci

1 exec p a r a l l e l . s c e ;
2 exec s e r i e s . s c e ;
3 syms G1 G2 G3 H1 H2 ;
4 // s h i f t the take − o f f point after the block G2
5 a=G3/G2 ;
6 b=p a r a l l e l ( a , 1 ) ;
7 c=s e r i e s (G1 , G2) ;
8 d=c / . H1 / / n e g a t i v e feedback operation
9 e=s e r i e s ( d , b ) ;
10 y=e / . H2 ;
11 y=s i m p l e ( y ) ;
12 disp ( y , ”C( s ) /R( s )=” )

Example 6.09 6.09.sci

24
1 exec s e r i e s . s c e
2 syms G1 G2 G3 H1 H2 H3 ;
3 // Remove the feedback loop having feedback path
transfer function H2
4 a=G3 / . H2 ;
5 // I n t e r c h a n g e the summer . as well as replace the
cascade block by its equivalent block
6 b=s e r i e s (G1 , G2) ;
7 c=b / . H1 ; / / N e g a t i v e Feedback Operation
8 d=s e r i e s ( c , a ) ;
9 y=d / . H3 ; / / N e g a t i v e Feedback Operation
10 y=s i m p l e ( y ) ;
11 disp ( y , ”C( s ) /R( s )=” )

Example 6.10 6.10.sci

1 exec p a r a l l e l . s c e ;
2 exec s e r i e s . s c e ;
3 syms G1 G2 G3 G4 G5 H1 H2 ;
4 a=G2 / . H1 ; / / n e g a t i v e f e e d b a c k operation
5 b=s e r i e s (G1 , a ) ;
6 c=s e r i e s ( b , G3) ;
7 d=p a r a l l e l ( c , G4) ;
8 e=s e r i e s ( d , G5) ;
9 y=e / . H2 ; // n e g a t i v e feedback operation
10 y=s i m p l e ( y ) ;
11 disp ( y , ”C( s ) /R( s )=” )

Example 6.11 6.11.sci

1 exec p a r a l l e l . s c e ;
2 exec s e r i e s . s c e ;
3 syms G1 G2 G3 G4 G5 G6 G7 H1 H2 H3 ;
4 a=p a r a l l e l (G1 , G2) ;
5 b=p a r a l l e l ( a , G3) ;
6 // s h i f t the take off point to the right of the block G4
7 c=G4 / . H1 ; // n e g a t i v e feedback operation
8 d=G5/G4 ; // n e g a t i v e feedback operation

25
9 e=p a r a l l e l ( d , 1 ) ;
10 f=G6 / . H2 ; // n e g a t i v e feedback operation
11 g=s e r i e s ( b , c ) ;
12 h=s e r i e s ( g , e ) ;
13 i=s e r i e s ( h , f ) ;
14 j=s e r i e s ( i , G7) ;
15 y=j / . H3 ;
16 y=s i m p l e ( y ) ;
17 disp ( y , ”C( s ) /R( s )=” )

Example 6.12 6.12.sci

1 exec s e r i e s . s c e ;
2 exec p a r a l l e l . s c e ;
3 syms G1 G2 G3 G4 H1 H2 H3 ;
4 // s h i f t the take − o f f point after the block G1
5 a=G3/G1 ;
6 b=p a r a l l e l ( a , G2) ;
7 c=G1 / . H1 ; / / N e g a t i v e F e e d b a c k O p e r a t i o n
8 d=1/b ; // N e g a t i v e Feedback Operation
9 e=p a r a l l e l ( d , H3) ;
10 f=s e r i e s ( e , H2) ;
11 g=s e r i e s ( c , b ) ;
12 h=g / . f ; // N e g a t i v e Feedback Operation
13 y=s e r i e s ( h , G4) ;
14 y=s i m p l e ( y ) ;
15 disp ( y , ”C( s ) /R( s )=” )

Example 6.13 6.13.sci

1 exec s e r i e s . s c e ;
2 exec p a r a l l e l . s c e ;
3 syms G1 G2 G3 G4 H1 H2 ;
4 // r e d u c e the internal feedback loop
5 a=G2 / . H2 ;
6 // p l a c e the summer l e f t to the block G1
7 b=G3/G1 ;
8 // e x c h a n g e the summer

26
9 c=p a r a l l e l ( b , 1 ) ;
10 d=s e r i e s ( a , G1) ;
11 e=s e r i e s ( d , G4) ;
12 f=e / . H1 ;
13 y=s e r i e s ( c , f ) ;
14 y=s i m p l e ( y ) ;
15 disp ( y , ”C( s ) /R( s )=” )

Example 6.14 6.14.sci

1 exec s e r i e s . s c e ;
2 exec p a r a l l e l . s c e ;
3 syms G1 G2 G3 G4 H1 H2 ;
4 // s h i f t the take − o f f point to the right of the block G3
5 a=H1/G3 ;
6 b=s e r i e s (G2 , G3) ;
7 c=p a r a l l e l (H2 , a ) ;
8 d=b / . c ;
9 e=s e r i e s ( d , G1) ;
10 f=e / . a ;
11 y=s e r i e s ( f , G4) ;
12 y=s i m p l e ( y ) ;
13 disp ( y , ”C( s ) /R( s )=” )

Example 6.15 6.15.sci

1 exec s e r i e s . s c e ;
2 exec p a r a l l e l . s c e ;
3 syms G1 G2 G3 G4 H1 H2 H3 ;
4 // s h i f t the take − o f f point to the right of the block H1
5 // s h i f t the other take − o f f point to the right of the
block H1 &H2
6 a=s e r i e s (H1 , H2) ;
7 b=1/a ;
8 c=1/H1 ;
9 d=G3 / . a ;
10 // move the summer to the l e f t of the block G2
11 e=G4/G2 ;

27
12 f=s e r i e s ( d , G2) ;
13 // e x c h a n g e the summer
14 g=f / . H1 ;
15 h=p a r a l l e l (G1 , e ) ;
16 i=s e r i e s ( h , g ) ;
17 j=s e r i e s ( a , H3) ;
18 y=i / . j ;
19 y=s i m p l e ( y ) ;
20 disp ( y , ”C( s ) /R( s )=” )

28
Chapter 8

Time Domain Analysis of


Control Systems

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox

8.1 Scilab Code


Example 8.02 8.02.sci

1 s=%s ;
2 p=poly ( [ 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 q=poly ( [ 0 1 0 . 9 5 0 . 2 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
4 G=p/q ;
5 disp (G, ”G( s )=” )
6 H=1;
7 y=G∗H; / / T y p e 1 S y s t e m
8 disp ( y , ”G( s )H( s )=” )
9 // R e f e r i n g the table 8.2 given in the book , For type 1
system Kp= % i n f & Ka =0
10 p r i n t f ( ” For type1 Kp=i n f & Ka=0 \n” )
11 syms s ;
12 Kv=l i m i t ( s ∗y , s , 0 ) ; / / K v = v e l o c i t y e r r o r c o e f f i c i e n t
13 disp (Kv , ” 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)=” )

29
Example 8.03-01 8.03.01.sci

1 s=%s ;
2 p=poly ( [ 1 0 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 q=poly ( [ 0 0 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
4 G=p/q ;
5 H= 0 . 7 ;
6 y=G∗H; / / t y p e 2
7 disp ( y , ”G( s )H( s )=” )
8 // r e f e r i n g the table 8.2 given in the book , for type 1
Kp= % i n f & Kv= % i n f
9 p r i n t f ( ” For type1 Kp=i n f & Kv=i n f \n” )
10 syms s ;
11 Ka=l i m i t ( s ˆ2∗y , s , 0 ) ; / / K a = a c c e l a r a t i o n error
c o e f f i c i e n t
12 disp (Ka , ”Ka=” )

Example 8.03-02 8.03.02.sci

1 p=poly ( [ 5 ] , ’ s ’ , ’ c o e f f ’ ) ;
2 q=poly ( [ 5 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 G=p/q
4 H=0.6
5 y=G∗H / / t y p e 0
6 // r e f e r i n g the table 8.2 given in the book , for type 1
Ka =0 & Kv =0
7 syms s
8 Kp=l i m i t ( s ∗y/ s , s , 0 ) // Kp= p o s i t i o n a l error c o e f f i c i e n t

Example 8.03-03 8.03.03.sci

2 p=poly ( [ 1 0 . 1 3 0 . 4 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 q=poly ( [ 0 0 5 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
4 G=10∗p/q / / g a i n FACTOR = 1 0
5 H=0.8
6 y=G∗H / / t y p e 2

30
7 // r e f e r i n g the table 8.2 given in the book , for type 2
Kp= % i n f & Kv= % i n f
8 syms s
9 Ka=l i m i t ( s ˆ2∗y , s , 0 ) / / Ka= a c c e l a r a t i o n error c o e f f i c i e n t

Example 8.04 8.04.sci

2 p=poly ( [ 4 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 q=poly ( [ 0 0 6 5 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
4 syms K r e a l ;
5 y=K∗p/q / / g a i n FACTOR =K
6 disp ( y , ”G( s )H( s )=” )
7 // G ( s ) H ( s ) =y , and it is of type 2
8 // r e f e r i n g the table 8.2 given in the book , for type 2
Kp= % i n f & Kv= % i n f
9 p r i n t f ( ” For type1 Kp=i n f & Kv=i n f \n” )
10 syms A s t ;
11 Ka=l i m i t ( s ˆ2∗y , s , 0 ) ; / / K a = a c c e l a r a t i o n error
c o e f f i c i e n t
12 disp (Ka , ”Ka=” )
13 // g i v e n input is r ( t ) =A ( t ˆ 2 ) / 2 & R( s )= l a p l a c e ( r ( t ) )
14 p r i n t f ( ” Given r ( t )=A( t ˆ 2) /2 \n” )
15 R=l a p l a c e ( ’A∗ t ˆ2/2 ’ , t , s ) ;
16 disp (R, ”R( s )=” )
17 // s t e a d y state error =Lt s − >0 sR ( S ) /1+G ( s ) H ( S )
18 e=l i m i t ( s ∗R/(1+y ) , s , 0 )
19 disp ( e , ” Ess=” )

Example 8.05 8.05.sci

1 p=poly ( [ 6 0 ] , ’ s ’ , ’ c o e f f ’ ) ;
2 q=poly ( [ 1 2 7 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 G=p/q ;
4 disp (G, ”G( s )=” )
5 H=1;
6 y=G∗H
7 F=1/(1+y ) ;

31
8 disp (F , ” 1/(1+G( s )H( s ) )=” )
9 syms t s ;
10 Ko=l i m i t ( s ∗F/ s , s , 0 ) / / K o = L t s − >0 ( 1 / ( 1 + G ( s ) H ( S ) )
11 d=d i f f ( s ∗F/ s , s ) ;
12 K1=l i m i t ( d i f f ( s ∗F/ s , s ) , s , 0 ) / / K 1 = L t s − >0 ( d F ( s ) / d s )
13 K2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s − >0 ( d 2 F ( s ) / d s )
14 // g i v e n input is r ( t ) =4+3∗ t +8( t ˆ 2 ) /2 & R( s )= l a p l a c e ( r ( t
) )
15 a=(4+3∗ t +8∗( t ˆ 2) / 2 )
16 b=d i f f (4+3∗ t +8∗( t ˆ 2) /2 , t )
17 c=d i f f ( b , t )
18 e=Ko∗a+K1∗b+K2∗ c / / e r r o r b y dynamic c o e f f i c i e n t method
19 disp ( e , ” e r r o r ” )

Example 8.06 8.06.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s a s polynomial variable


2 F=s y s l i n ( ’ c ’ , [ 2 5 / ( ( s +1)∗ s ) ] ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 CL=F / .B // C a l c u l a t e s closed −loop transfer function
5 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
6 y=denom(CL) // e x t r a c t i n g the denominator of CL
7 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
8 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
9 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
10 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
11 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
12 Wd=Wn∗ sqrt (1− z e t a ˆ 2)
13 Tp=%pi/Wd
14 Mp=100∗exp((−%pi∗ z e t a ) / sqrt (1− z e t a ˆ 2) )

Example 8.07 8.07.sci

1 s=poly ( 0 , ’ s ’ ) ; // D e f i n e s s as polynomial variable

32
2 F=s y s l i n ( ’ c ’ , [ 2 0 / ( s ˆ2+5∗ s +5) ] ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 CL=F / .B // C a l c u l a t e s closed −loop transfer function
5 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
6 y=denom(CL) // e x t r a c t i n g the denominator of CL
7 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
8 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
9 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
10 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
11 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
12 Wd=Wn∗ sqrt (1− z e t a ˆ 2)
13 Tp=%pi/Wd / / Tp= p e a k t i m e
14 Mp=100∗exp((−%pi∗ z e t a ) / sqrt (1− z e t a ˆ 2) ) / / p e a k
overshoot
15 Td=(1+0.7∗ z e t a ) /Wn / / Td= d e l a y t i m e
16 a=atan ( sqrt (1− z e t a ˆ 2) / z e t a )
17 Tr=(%pi−a ) /Wd // Tr= r i s e time
18 Ts=4/( z e t a ∗Wn) // Ts= s e t t l i n g time

Example 8.08 8.08.sci

1 p=poly ( [ 1 4 0 , 3 5 ] , ’ s ’ , ’ c o e f f ’ ) ;
2 q=poly ( [ 0 , 1 0 , 7 , 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 G=p/q
4 H=1
5 y=G∗H / / t y p e 1
6 // r e f e r i n g the table 8.2 given in the book , for type 1
Kp= % i n f & Ka =0
7 syms s
8 Kv=l i m i t ( s ∗y , s , 0 ) / / Kv= velocity error c o e f f i c i e n t
9 // g i v e n input is r ( t ) =5∗ t & R( s )= l a p l a c e ( r ( t ) )
10 R=l a p l a c e ( ’ 5∗ t ’ , t , s )
11 // s t e a d y state error =Lt s − >0 sR ( S ) /1+G ( s ) H ( S )
12 e=l i m i t ( s ∗R/(1+y ) , s , 0 ) / / e = e r r o r for ramp input
13 disp ( e , ” s t e a d y s t a t e e r r o r ” )

33
Example 8.09 8.09.sci

1 p=poly ( [ 4 0 , 2 0 ] , ’ s ’ , ’ c o e f f ’ ) ;
2 q=poly ( [ 0 , 0 , 5 , 6 , 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 G=p/q ;
4 H=1;
5 y=G∗H; / / t y p e 2
6 disp ( y , ”G( s )H( s=” )
7 // r e f e r i n g the table 8.2 given in the book , for type 2
Kp= % i n f & Kv= % i n f
8 syms s t ;
9 Ka=l i m i t ( s ˆ2∗y , s , 0 ) / / Ka= accelaration error
c o e f f i c i e n t
10 // g i v e n input is r ( t ) =1+3 t + t ˆ 2 / 2 & R( s )= l a p l a c e ( r ( t ) )
11 R=l a p l a c e ( ’ (1+3∗ t +( t ˆ2/2) ) ’ , t , s )
12 // s t e a d y state error =Lt s − >0 sR ( S ) /1+G ( s ) H ( S )
13 e=l i m i t ( s ∗R/(1+y ) , s , 0 ) / / e = e r r o r for ramp input
14 disp ( e , ” s t e a d y s t a t e e r r o r ” )

Example 8.10 8.10.sci

1 s = poly ( 0 , ’ s ’ )
2 s y s = s y s l i n ( ’ c ’ , ( 2 0 ) / ( s ˆ2+7∗ s +10) )
3 a=s y s / . ( 2 ∗ ( s +1) ) / / s i m p l i f y i n g t h e internal feedback
loop
4 b=20∗2∗a ;
5 disp ( b , ”G( s ) ” )
6 c =1;
7 disp ( c , ”H( s ) ” )
8 OL=b∗ c ;
9 disp (OL, ”G( s )H( s ) ” )
10 , ”G( s ) ∗H( s ) ” )
11 syms t s ;
12 Kp=l i m i t ( s ∗OL/ s , s , 0 ) / / K p = p o s i t i o n e r r o r c o e f f i c i e n t
13 Kv=l i m i t ( s ∗OL, s , 0 ) / / K v = v e l o c i t y e r r o r c o e f f i c i e n t
14 Ka=l i m i t ( s ˆ2∗OL, s , 0 ) / / K a = a c c e l a r a t i o n e r r o r
c o e f f i c i e n t

34
15 // g i v e n input r ( t ) =6
16 R=l a p l a c e ( ’ 6 ’ , t , s )
17 // s t e a d y state error =Lt s − >0 sR ( S ) /1+G ( s ) H ( S )
18 e1=l i m i t ( s ∗R/(1+OL) , s , 0 ) ; // e= e r r o r for given input
19 disp ( e1 , ” e r r o r ” )
20 // g i v e n input r ( t ) =8 t
21 M=l a p l a c e ( ’ 8∗ t ’ , t , s )
22 // s t e a d y state error =Lt s − >0 sR ( S ) /1+G ( s ) H ( S )
23 e2=l i m i t ( s ∗M/(1+OL) , s , 0 ) ; // e= e r r o r for given input
24 disp ( e2 , ” e r r o r ” )
25 // g i v e n input r ( t ) = 1 0 + 4 t +3 t ˆ 2 / 2
26 N=l a p l a c e ( ’ 10+4∗ t +(3∗ t ˆ 2) /2 ’ , t , s )
27 // s t e a d y state error =Lt s − >0 sR ( S ) /1+G ( s ) H ( S )
28 e3=l i m i t ( s ∗N/(1+OL) , s , 0 ) ; // e= e r r o r for given input
29 disp ( e3 , ” e r r o r ” )

Example 8.11 8.11.sci

1 s = poly ( 0 , ’ s ’ )
2 s y s 1 = s y s l i n ( ’ c ’ , ( s ) / ( s +6) ) ;
3 s y s 2 = s y s l i n ( ’ c ’ , ( s +2) / ( s +3) ) ;
4 s y s 3 = s y s l i n ( ’ c ’ , ( 5 ) / ( ( s +3)∗ s ˆ 3 ) ) ;
5 a=s y s 2+s y s 3 ;
6 disp ( a , ”H( s ) ” )
7 b=s y s 1 ;
8 disp ( b , ”G( S ) ” )
9 y=a∗b ;
10 disp ( y , ”G( S )H( S ) ” )
11 syms s
12 Kp=l i m i t ( s ∗y/ s , s , 0 ) / / K p = p o s i t i o n e r r o r c o e f f i c i e n t
13 Kv=l i m i t ( s ∗y , s , 0 ) / / K v = v e l o c i t y e r r o r c o e f f i c i e n t
14 Ka=l i m i t ( s ˆ2∗y , s , 0 ) / / K a = a c c e l a r a t i o n e r r o r
c o e f f i c i e n t

Example 8.12 8.12.sci

1 s=%s ;
2 syms k t ;

35
3 y=k / ( ( s +1)∗ s ˆ2∗( s +4) ) ;
4 disp ( y , ”G( s )H( s )=” )
5 r =1+(8∗ t ) +(18∗ t ˆ2/2) ;
6 disp ( r , ” r ( t )=” )
7 R=l a p l a c e ( r , t , s ) ;
8 disp (R, ”R( s )=” )
9 e=l i m i t ( ( s ∗R) /(1+y ) , s , 0 )
10 disp ( e , ” Ess=” )
11 p r i n t f ( ’ Given Ess = 0 . 8 \n ” )
12 e =0.8;
13 k=72/e ;
14 d i s p ( k , ” k=”)

Example 8.13 8.13.sci

1 syms s t k ;
2 s = poly ( 0 , ’ s ’ ) ;
3 y=k / ( s ∗( s +2) ) ; / / G ( s )H( s )
4 disp ( y , ”G( s )H( s ) ” )
5 / / R= l a p l a c e ( ’ 0 . 2 ∗ t ’ , t , s )
6 R=l a p l a c e ( ’ 0 . 2 ∗ t ’ , t , s )
7 e=l i m i t ( s ∗R/(1+y ) , s , 0 )
8 // g i v e n e <=0.02
9 a =[0.02];
10 b=[ −0.4];
11 m=l i n s o l v e ( a , b ) ; // S o l v e s The Linear Equation
12 disp (m, ”k” )

Example 8.14 8.14.sci

1 syms s , t , k ;
2 s=%s ;
3 y=k / ( s ∗( s +2) ∗(1+0.5∗ s ) ) //G( s )H( s )
4 disp ( y , ”G( s )H( s ) ” )
5 / / R= l a p l a c e ( ’ 3 ∗ t ’ , t , s )
6 R=l a p l a c e ( ’ 3∗ t ’ , t , s )
7 e=l i m i t ( s ∗R/(1+y ) , s , 0 ) ;
8 disp ( e , ” s t e a d y s t a t e e r r o r ” )

36
9 k=4; / / g i v e n
10 y=e ;
11 disp ( y , ” s t a t e s t a t e e r r o r when k=4” )

Example 8.15 8.15.sci

1 s = poly ( 0 , ’ s ’ ) ;
2 s y s = s y s l i n ( ’ c ’ , 1 8 0 / ( s ∗( s +6) ) ) //G( s )H( s )
3 disp ( sys , ”G( s )H( s ) ” )
4 syms t s ;
5 / / R= l a p l a c e ( ’ 4 ∗ t ’ , t , s )
6 R=l a p l a c e ( ’ 4∗ t ’ , t , s ) ;
7 e=l i m i t ( s ∗R/(1+ s y s ) , s , 0 ) ;
8 y=db l ( e ) ;
9 disp ( y , ” s t e a d y s t a t e e r r o r ” )
10 syms k r e a l ;
11 // v a l u e of k if error reduced by 6% ;
12 e1=l i m i t ( s ∗R/(1+k / ( s ∗( s +6) ) ) , s , 0 ) / / −−−−−−−1
13 e1 =0.94∗ e / / −−−−−−−−2
14 // now solving these two equations
15 a =[47];
16 b =[ −9000];
17 m=l i n s o l v e ( a , b ) ;
18 disp (m, ”k” )

Example 8.16 8.16.sci

1 s=%s ;
2 F=s y s l i n ( ’ c ’ , ( 8 1 ) / ( s ˆ2+6∗ s ) ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 CL=F / .B // C a l c u l a t e s closed −loop transfer function
5 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
6 y=denom(CL) // e x t r a c t i n g the denominator of CL
7 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
8 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s

37
9 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
10 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
11 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
12 Wd=Wn∗ sqrt (1− z e t a ˆ 2)
13 Tp=%pi/Wd / / Tp= p e a k t i m e
14 Mp=100∗exp((−%pi∗ z e t a ) / sqrt (1− z e t a ˆ 2) ) / / p e a k
overshoot

Example 8.17 8.17.sci

1 s=%s ;
2 F=s y s l i n ( ’ c ’ , ( 2 5 ) / ( s ˆ2+7∗ s ) ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 k =20/25; // k= g a i n factor
5 CL=k ∗(F / .B) / / C a l c u l a t e s c l o s e d −loop transfer function
6 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
7 y=denom(CL) // e x t r a c t i n g the denominator of CL
8 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
9 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
10 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
11 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
12 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
13 Wd=Wn∗ sqrt (1− z e t a ˆ 2)
14 Tp=%pi/Wd / / Tp= p e a k t i m e
15 Mp=100∗exp((−%pi∗ z e t a ) / sqrt (1− z e t a ˆ 2) ) / / p e a k
overshoot
16 Td=(1+0.7∗ z e t a ) /Wn / / Td= d e l a y t i m e
17 a=atan ( sqrt (1− z e t a ˆ 2) / z e t a )
18 Tr=(%pi−a ) /Wd // Tr= r i s e time
19 Ts=4/( z e t a ∗Wn) // Ts= s e t t l i n g time
20 // y ( t )= e x p r e s s i o n for output
21 y =(20/25) ∗(1 −(exp(−1∗ z e t a ∗Wn∗ t ) / sqrt (1− z e t a ˆ 2) ) ∗ sin (Wd∗
t+atan ( z e t a / sqrt (1− z e t a ˆ 2) ) ) ) ;
22 disp ( y , ”Y( t ) ” )

38
Example 8.19 8.19.sci

1 s=%s ;
2 F=s y s l i n ( ’ c ’ , ( 1 4 4 ) / ( s ˆ2+12∗ s ) ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 k =20/25; // k= g a i n factor
5 CL=k ∗(F / .B) / / C a l c u l a t e s c l o s e d −loop transfer function
6 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
7 y=denom(CL) // e x t r a c t i n g the denominator of CL
8 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
9 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
10 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
11 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
12 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
13 Wd=Wn∗ sqrt (1− z e t a ˆ 2)
14 Tp=%pi/Wd / / Tp= p e a k t i m e
15 Mp=100∗exp((−%pi∗ z e t a ) / sqrt (1− z e t a ˆ 2) ) / / p e a k
overshoot
16 Td=(1+0.7∗ z e t a ) /Wn / / Td= d e l a y t i m e
17 a=atan ( sqrt (1− z e t a ˆ 2) / z e t a )
18 Tr=(%pi−a ) /Wd // Tr= r i s e time
19 Ts=4/( z e t a ∗Wn) // Ts= s e t t l i n g time

Example 8.20 8.20.sci

1 i eee ( 2 ) ;
2 syms k T;
3 num=k ;
4 den=s ∗(1+ s ∗T) ;
5 G=num/ den ;
6 disp (G, ”G( s )=” )
7 H=1;
8 CL=G/ .H;
9 CL=s i m p l e (CL) ;

39
10 disp (CL, ”C( s ) /R( s )=” ) // C a l c u l a t e s closed −loop
transfer function
11 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
12 [ num , den ]=numden (CL) // e x t r a c t s num & den of symbolic
function ( CL )
13 den=den /T;
14 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) // coeff of den of symbolic
function ( CL )
15 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )
16 / / Wn ˆ 2 = cof a 0 , comparing the c o e f f i c i e n t s
17 Wn=sqrt ( c o f a 0 )
18 disp (Wn, ” n a t u r a l f r e q u e n c y Wn” ) // Wn= n a t u r a l
frequency
19 // c o f a 1 = 2 ∗ z e t a ∗ Wn
20 z e t a=c o f a 1 /(2∗Wn)

Example 8.23-01 8.23.01.sci

1 s= poly ( 0 , ’ s ’ ) ;
2 s y s = s y s l i n ( ’ c ’ , 1 0 / ( s +2) ) ; / / G ( s )H( s )
3 disp ( sys , ”G( s )H( s ) ” )
4 F=1/(1+ s y s )
5 syms t s ;
6 Co=l i m i t ( s ∗F/ s , s , 0 ) / / K o = L t s − >0 (1/(1+G( s )H( S ) )
7 a =(3) ;
8 e=Co∗a ;
9 disp ( e , ” s t e a d y s t a t e e r r o r ” )

Example 8.23-02 8.23.02.sci

1 s= poly ( 0 , ’ s ’ ) ;
2 s y s = s y s l i n ( ’ c ’ , 1 0 / ( s +2) ) ; / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )
4 F=1/(1+ s y s )
5 syms t s ;
6 Co=l i m i t ( s ∗F/ s , s , 0 ) / / K o = L t s − >0 ( 1 / ( 1 + G ( s )H( S ) )
7 d=d i f f ( s ∗F/ s , s )
8 C1=l i m i t ( d i f f ( s ∗F/ s , s ) , s , 0 ) / / K 1 = L t s − >0 ( dF ( s ) / d s )

40
9 a=(2∗ t ) ;
10 b=d i f f ( ( 2 ∗ t ) , t ) ;
11 e=Co∗a+C1∗b ;
12 disp ( e , ” s t e a d t s t a t e e r r o r ” )

Example 8.23-03 8.23.03.sci

1 s= poly ( 0 , ’ s ’ ) ;
2 s y s = s y s l i n ( ’ c ’ , 1 0 / ( s +2) ) ; / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )
4 F=1/(1+ s y s )
5 syms t s ;
6 Co=l i m i t ( s ∗F/ s , s , 0 ) / / K o = L t s − >0 ( 1 / ( 1 + G ( s ) H ( S ) )
7 d=d i f f ( s ∗F/ s , s )
8 C1=l i m i t ( d i f f ( s ∗F/ s , s ) , s , 0 ) / / K 1 = L t s − >0 ( d F ( s ) / d s )
9 C2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s − >0 ( d 2 F ( s ) / d s )
10 a =(( t ˆ2 ) / 2) ;
11 b=d i f f ( ( t ˆ 2) /2 , t ) ;
12 c=d i f f ( b , t ) ;
13 e=Co∗a+C1∗b+C2∗ c ;
14 disp ( e , ” s t e a d y s t a t e e r r o r ” )

Example 8.23-04 8.23.04.sci

1 s= poly ( 0 , ’ s ’ ) ;
2 s y s = s y s l i n ( ’ c ’ , 1 0 / ( s +2) ) ; / / G ( s ) H ( s )
3 disp ( sys , ”G( s )H( s ) ” )
4 F=1/(1+ s y s )
5 syms t s ;
6 Co=l i m i t ( s ∗F/ s , s , 0 ) / / K o = L t s − >0 ( 1 / ( 1 + G ( s ) H ( S ) )
7 d=d i f f ( s ∗F/ s , s )
8 C1=l i m i t ( d i f f ( s ∗F/ s , s ) , s , 0 ) / / K 1 = L t s − >0 ( d F ( s ) / d s )
9 C2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s − >0 ( d 2 F ( s ) / d s )
10 // g i v e n input is r ( t ) =1+2∗ t +( t ˆ 2 ) / 2 & R( s )= l a p l a c e ( r ( t )
)
11 a=(1+2∗ t +( t ˆ 2) /2 ) ;
12 b=d i f f ( a , t ) ;
13 c=d i f f ( b , t ) ;

41
14 e=Co∗a+C1∗b+C2∗ c // e r r o r by dynamic c o e f f i c i e n t method

Example 8.24 8.24.sci

1 s= poly ( 0 , ’ s ’ ) ;
2 s y s 1 = s y s l i n ( ’ c ’ , ( s +3) / ( s +5) ) ;
3 s y s 2= s y s l i n ( ’ c ’ , ( 1 0 0 ) / ( s +2) ) ;
4 s y s 3= s y s l i n ( ’ c ’ , ( 0 . 1 5 ) / ( s +3) ) ;
5 G=s y s 1 ∗ s y s 2 ∗ s y s 3 ∗2∗5
6 H=1;
7 y=G∗H; / / G ( s ) H ( s )
8 disp ( y , ”G( s )H( s ) ” )
9 F=1/(1+y )
10 syms t s ;
11 Co=l i m i t ( s ∗F/ s , s , 0 ) / / K o = L t s − >0 ( 1 / ( 1 + G ( s ) H ( S ) )
12 d=d i f f ( s ∗F/ s , s )
13 C1=l i m i t ( d i f f ( s ∗F/ s , s ) , s , 0 ) / / K 1 = L t s − >0 ( d F ( s ) / d s )
14 C2=l i m i t ( d i f f ( d , s ) , s , 0 ) / / K 2 = L t s − >0 ( d 2 F ( s ) / d s )
15 a=(1+(2∗ t ) +(5∗( t ˆ2/2) ) ) ;
16 b=d i f f ( a , t ) ;
17 c=d i f f ( b , t ) ;
18 e=Co∗a+C1∗b+C2∗ c ;
19 disp ( e , ” s t e a d t s t a t e e r r o r ” )

Example 8.32 8.32.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ ,(9∗(1+2∗ s ) ) / ( s ˆ2+0.6∗ s +9) ) ;
3 disp ( sys , ”C( s ) /R( s )=” )
4 // g i v e n r ( t ) =u ( t )
5 syms t s ;
6 R=l a p l a c e ( ’ 1 ’ , t , s ) ;
7 disp (R, ”R( s )=” )
8 C=R∗ s y s ;
9 disp (C, ”C( s )=” )
10 c=i l a p l a c e (C, s , t )
11 disp ( c , ” c ( t )=” )
12 G=9/( s ˆ3+0.6∗ s ˆ 2 ) ;

42
13 disp (G, ”G( s )=” )
14 H=1;
15 y=1+G∗H;
16 syms t s ;
17 Kp=l i m i t ( s ∗G/ s , s , 0 )
18 Kv=l i m i t ( s ∗G, s , 0 )
19 Ka=l i m i t ( s ˆ2∗G, s , 0 )
20 R=l a p l a c e ( ’ (1+ t +( t ˆ2/2) ) ’ , t , s )
21 // s t e a d y state error =Lt s − >0 sR ( S ) /1+G ( s ) H ( S )
22 e=l i m i t ( s ∗R/(1+y ) , s , 0 ) ; / / e = e r r o r for ramp input
23 disp ( e , ” s t e a d y s t a t e e r r o r ( Ess ) ” )

43
Chapter 9

Feedback Characteristics of
control Systems

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox

9.1 Scilab Code


Example 9.01 9.01.sci

1 s=%s ;
2 G=s y s l i n ( ’ c ’ , 2 0 / ( s ∗( s +4) ) )
3 H= 0 . 3 5 ;
4 y=G∗H;
5

6 S=1/(1+y ) ;
7 disp ( S , ” 1/(1+G( s ) ∗H( s ) ) ” )
8

9 // g i v e n w=1.2
10 w=1.2
11 s=%i∗w
12 S=horner ( S , s ) / / c a l c u l a t e s v a l u e o f S at s
13 a=abs ( S )
14 disp ( a , ” s e n s i t i v i t y o f open l o o p ” )
15

44
16 F=−y/(1+y )
17 disp (F , ”(−G( s ) ∗H( s ) ) /(1+G( s ) ∗H( s ) ) ” )
18 S=horner (F , s ) / / c a l c u l a t e s v a l u e o f F at s
19 b=abs ( S )
20 disp ( b , ” s e n s i t i v i t y o f c l o s e d l o o p ” )

Example 9.02 9.02.sci

1 s=%s ;
2 s y s 1=s y s l i n ( ’ c ’ , 9 / ( s ∗( s +1.8) ) ) ;
3 syms Td ;
4 s y s 2 =1+(s ∗Td) ;
5 s y s 3=s y s 1 ∗ s y s 2 ;
6 H=1;
7 CL=s y s 3 / .H; / / C a l c u l a t e s c l o s e d − l o o p transfer function
8 disp (CL, ”C( s ) /R( s ) ” )
9 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
10 [ num , den ]=numden (CL) // e x t r a c t s num & den of symbolic
function CL
11 den=den / 5 ;
12 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) // coeff of den of symbolic
function CL
13 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )
14 / / Wn ˆ 2 = cof a 0 , comparing the c o e f f i c i e n t s
15 Wn=sqrt ( c o f a 0 )
16 disp (Wn, ” n a t u r a l f r e q u e n c y Wn” ) // Wn= n a t u r a l
frequency
17 // c o f a 1 = 2 ∗ z e t a ∗ Wn
18 z e t a=c o f a 1 /(2∗Wn)
19 z e t a =1; disp ( z e t a , ” f o r c r i t i c a l y damped f u n c t i o n z e t a ” )
20 Td=((2∗Wn) −1.8) /9
21 Ts=4/( z e t a ∗Wn) ;
22 Ts=d bl ( Ts ) ;
23 disp ( Ts , ” s e t t l i n g time Ts” )

Example 9.03 9.03.sci

1 s=%s ;

45
2 G=s y s l i n ( ’ c ’ , 4 0 / ( s ∗( s +4) ) )
3 H= 0 . 5 0 ;
4 y=G∗H;
5 S=1/(1+y ) ;
6 disp ( S , ” 1/(1+G( s ) ∗H( s ) ) ” )
7 // g i v e n w=1.3
8 w=1.3
9 s=%i∗w
10 S=horner ( S , s )
11 a=abs ( S )
12 disp ( a , ” s e n s i t i v i t y o f open l o o p ” )
13 F=−y/(1+y )
14 disp (F , ”(−G( s ) ∗H( s ) ) /(1+G( s ) ∗H( s ) ) ” )
15 S=horner (F , s )
16 b=abs ( S )
17 disp ( b , ” s e n s i t i v i t y o f c l o s e d l o o p ” )

Example 9.04 9.04.sci

1 s=%s ;
2 syms s ;
3 syms Wn z e t a A H r e a l ;
4 T= 6 . 2 8 ;
5 Wn=(8∗%pi ) /T;
6 z e t a =0.3
7 n=Wnˆ 2 ;
8 d=s ˆ2+2∗ z e t a ∗Wn∗ s+Wnˆ 2 ;
9 G1=n/d ;
10 disp (G1 , ”G1( s ) ” )
11 G=A∗G1 ;
12 disp (G, ”G( s ) ” )
13 S1=( d i f f (G,A) ) ∗(A/G) ;
14 a=s i m p l e ( S1 ) ;
15 disp ( a , ” open l o o p s e n s i t i v i t y f o r changes i n A” )
16 M=G/ .H;
17 p=s i m p l e (M)
18 S2=( d i f f ( p ,A) ) ∗(A/p ) ;
19 b=s i m p l e ( S2 ) ;

46
20 disp ( b , ” c l o s e d l o o p s e n s i t i v i t y f o r changes i n A” )
21 S3=( d i f f ( p ,H) ) ∗(H/p ) ;
22 c=s i m p l e ( S3 ) ;
23 disp ( c , ” c l o s e d l o o p s e n s i t i v i t y f o r changes i n H” )

Example 9.05 9.05.sci

1 s=%s ;
2 s y s 1=s y s l i n ( ’ c ’ , ( s +3)/ s ) ;
3 syms u rp k H RL ;
4 num2=u∗RL∗ s ∗( s +2) ;
5 den2=(rp+RL) ∗( s +3) ;
6 s y s 2=num2/ den2 ;
7 num3=k ;
8 den3=s +2;
9 s y s 3=num3/ den3 ;
10 s y s=s y s 1 ∗ s y s 2 ∗ s y s 3 ;
11 disp ( sys , ”G( s )=” ) ;
12 RL=10∗10ˆ3;
13 rp =4∗10ˆ3;
14 s y s=eval ( s y s )
15 s y s=f l o a t ( s y s )
16 disp ( sys , ” s y s=” ) ;
17 disp (H, ”H( s ) ” ) ;
18 M=s y s / .H / / G ( s ) / 1 + G ( s ) H ( S )
19 M=s i m p l e (M)
20 S=( d i f f (M, u ) ) ∗( u/M) ;
21 S=s i m p l e ( S ) ;
22 disp ( S , ” system s e n s i t i v i t y due t o v a r i a t i o n o f u=” ) ;
23 H= 0 . 3 ;
24 u=12;
25 S=eval ( S ) / / −−−−−−−−− e q 1
26 S=0.04;
27 k =((7/S ) −7)/18 ; / / f r o m e q 1
28 disp ( k , ”K=” )

Example 9.06 9.06.sci

47
1 G=210;
2 H= 0 . 1 2 ;
3 syms Eo Er
4 p r i n t f ( ” f o r c l o s e d l o o p system ” )
5 s y s=G/ .H; / / E o / E r =G / ( 1 + GH )
6 disp ( sys , ”Eo/Er=” )
7 Eo=240 / / g i v e n
8 Er=Eo / 8 . 0 1 5 2 ;
9 disp ( Er , ”Er=” )
10 p r i n t f ( ” f o r open l o o p system ” )
11 disp (G, ”Eo/Er=” )
12 Er=Eo/G;
13 G=210;
14 disp ( Er , ”Er=” )
15 // p r i n t f (” s i n c e G is reduced by 12%, the new value of
gain is 784.8 V”) ;
16 S=1/(1+G∗H)
17 disp ( S , ” ( %change i n M) / ( %change i n G)=” )
18 disp ( 1 2 , ”%CHANGE IN G=” )
19 y =12∗0.03869;
20 disp ( y , ”%CHANGE IN M=” )
21 p r i n t f ( ” f o r open l o o p system ” )
22 disp ( 2 8 . 8 ∗ 1 0 0 / 2 4 0 , ”%change i n Eo” )

Example 9.07 9.07.sci

1 s=%s ;
2 s y s 1=s y s l i n ( ’ c ’ , 2 0 / ( s ∗( s +2) ) ) ;
3 syms Kt ;
4 s y s 2=Kt∗ s ;
5 s y s 3=s y s 1 / . s y s 2 ;
6 p=s i m p l e ( s y s 3 ) ;
7 disp ( p , ”G( s )=” )
8 H=1;
9 s y s=s y s 3 / .H;
10 s y s=s i m p l e ( s y s ) ;
11 disp ( sys , ”C( s ) /R( s )=” )
12 [ num , den ]=numden ( s y s )

48
13 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) // coeff of den of symbolic
function CL
14 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )
15 / / Wn ˆ 2 = cof a 0 , comparing the c o e f f i c i e n t s
16 Wn=sqrt ( c o f a 0 )
17 Wn=db l (Wn) ;
18 disp (Wn, ” n a t u r a l f r e q u e n c y Wn=” ) // Wn=
natural frequency
19 // c o f a 1 = 2 ∗ z e t a ∗ Wn
20 z e t a=c o f a 1 /(2∗Wn)
21 zeta =0.6;
22 Kt=((2∗ z e t a ∗Wn) −2) / 2 0 ;
23 disp ( Kt , ”Kt=” )
24 Wd=Wn∗ sqrt (1− z e t a ˆ 2) ;
25 disp (Wd, ”Wd=” )
26 Tp=%pi/Wd;
27 disp (Tp , ”Tp=” )
28 Mp=100∗exp((−%pi∗ z e t a ) / sqrt (1− z e t a ˆ 2) ) ;
29 disp (Mp, ”Mp=” )
30 Ts=4/( z e t a ∗Wn) ;
31 disp ( Ts , ”Ts=” )

Example 9.08 9.08.sci

1 s=%s ;
2 p r i n t f ( ” 1 ) z e t a & Wn without Kd” )
3 G=60∗ s y s l i n ( ’ c ’ , 1 / ( s ∗( s +4) ) ) ;
4 disp (G, ”G( S )=” )
5 CL=G/ .H;
6 disp (CL, ”C( s ) /R( s )=” )
7 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r of CL
8 z=c o e f f ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s of the
denominator polynomial
9 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
10 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
11 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
12 z e t a=z ( 1 , 2 ) /(2∗Wn)
13 s y s 1=s y s l i n ( ’ c ’ , 1 / ( s ∗( s +4) ) ) ;

49
14 syms Kd ;
15 p r i n t f ( ” 2 )Kd f o r z e t a =0.60 with c o n t r o l l e r ” )
16 s y s 2=s ∗Kd ;
17 s y s 3=s y s 1 / . s y s 2 ;
18 G=s y s 3 ∗ 6 0 ;
19 disp (G, ”G( s )=” )
20 H=1;
21 s y s=G/ .H;
22 disp ( sys , ”C( s ) /R( s )=” )
23 [ num , den ]=numden ( s y s )
24 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 )
25 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )
26 / / Wn ˆ 2 = cof a 0 , comparing the c o e f f i c i e n t s
27 Wn=sqrt ( c o f a 0 )
28 Wn=db l (Wn) ;
29 disp (Wn, ” n a t u r a l f r e q u e n c y Wn=” )
30 // c o f a 1 = 2 ∗ z e t a ∗ Wn
31 z e t a =0.60
32 Kd=(2∗ z e t a ∗Wn)−4

Example 9.09 9.09.sci

1 s=%s ;
2 p r i n t f ( ” 1 ) without c o n t r o l l e r ” )
3 G=s y s l i n ( ’ c ’ , 1 2 0 / ( s ∗( s +12.63) ) ) ;
4 disp (G, ”G( s )=” )
5 H=1;
6 CL=G/ .H;
7 disp (CL, ”C( s ) /R( s )=” )
8 y=denom(CL) / / e x t r a c t i n g t h e d e n o m i n a t o r of CL
9 z=c o e f f ( y ) / / e x t r a c t i n g t h e c o e f f i c i e n t s of the
denominator polynomial
10 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
11 Wn=sqrt ( z ( 1 , 1 ) ) ;
12 disp (Wn, ”Wn=” ) // Wn= n a t u r a l frequency
13 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
14 z e t a=z ( 1 , 2 ) /(2∗Wn) ;
15 disp ( z e t a , ” z e t a=” )

50
16 p r i n t f ( ” 2 ) with c o n t r o l l e r ’ )
17 G=s y s l i n ( ’ c ’ , ( 1 2 0 ∗ ( 3 0 + s ) ) / ( s ∗( s +12.63) ∗30) ) ;
18 d i s p (G, ”G( s )=” )
19 CL=G/ .H;
20 d i s p (CL, ”C( s ) /R( s )=” )
21 den=denom (CL)
22 den=den /30 // e x t r a c t i n g t he denominator o f CL
23 z=c o e f f ( den ) // e x t r a c t i n g t he c o e f f i c i e n t s o f t he
denominator p o l y n o m i a l
24 //Wnˆ2=z ( 1 , 1 ) , comparing t he c o e f f i c i e n t s
25 Wn=s q r t ( z ( 1 , 1 ) ) ;
26 d i s p (Wn, ”Wn=” ) // Wn=n a t u r a l f r e q u e n c y
27 //2∗ z e t a ∗Wn=z ( 1 , 2 )
28 z e t a=z ( 1 , 2 ) /(2∗Wn) ;
29 Mp=100∗ exp ((−%pi∗ z e t a ) / s q r t (1− z e t a ˆ 2) ) ;
30 d i s p (Mp, ”Mp=” )
31 Ts=4/( z e t a ∗Wn) ;
32 d i s p ( Ts , ”Ts=” )

Example 9.10 9.10.sci

1 s=%s ;
2 p r i n t f ( ” 1 ) without c o n t r o l l e r ” )
3 G=64∗ s y s l i n ( ’ c ’ , 1 / ( s ∗( s +4) ) ) ;
4 disp (G, ”G( s )=” )
5 H=1;
6 CL=G/ .H;
7 disp (CL, ”C( s ) /R( s )=” )
8 // E x t r a c t i n g the denominator of CL
9 y=denom(CL)
10 // E x t r a c t i n g the c o e f f i c i e n t s of the denominator
polynomial
11 z=c o e f f ( y )
12 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
13 Wn=sqrt ( z ( 1 , 1 ) ) ;
14 / / Wn= n a t u r a l frequency
15 disp (Wn, ”Wn=” )
16 p r i n t f ( ” 2 ) with c o n t r o l l e r ’ )

51
17 syms K;
18 s y s 1=s y s l i n ( ’ c ’ , 1 / ( s ∗( s +4) ) ) ;
19 s y s 2=s y s 1 / . ( s ∗K) ;
20 G=64∗ s y s 2
21 d i s p (G, ”G( s )=” )
22

23 s y s=G/ .H;
24 s y s=s i m p l e ( s y s ) ;
25 d i s p ( sys , ”C( s ) /R( s )=” )
26 [ num , den ]=numden ( s y s )
27 // C o e f f o f den o f s y m b o l i c f u n c t i o n CL
28 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 )
29 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )
30 //Wnˆ2= c o f a 0 , comparing t he c o e f f i c i e n t s
31 Wn=s q r t ( c o f a 0 )
32 Wn=db l (Wn) ;
33 //Wn=n a t u r a l f r e q u e n c y
34 d i s p (Wn, ” n a t u r a l f r e q u e n c y Wn=” )
35 // c o f a 1 =2∗ z e t a ∗Wn
36 z e t a=c o f a 1 /(2∗Wn)
37 zeta =0.6;
38 k=(16∗ z e t a )−4
39 d i s p ( k , ”K=” )

Example 9.11 9.11.sci

1 p r i n t f ( ” 2 ) with c o n t r o l l e r ’ )
2 syms K;
3 s y s 1=s y s l i n ( ’ c ’ , 1 / ( s ∗( s +1.2) ) ) ;
4 s y s 2=s y s 1 / . ( s ∗K) ;
5 G=16∗ s y s 2 ;
6 G=s i m p l e (G)
7 d i s p (G, ”G( s )=” )
8 s y s=G/ .H;
9 s y s=s i m p l e ( s y s ) ;
10 d i s p ( sys , ”C( s ) /R( s )=” )
11 [ num , den ]=numden ( s y s )
12 den=den / 5 ; // so t h a t c o e f f o f s ˆ2=1

52
13 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) // c o e f f o f den o f s y m b o l i c
f u n c t i o n CL
14 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 )
15 //Wnˆ2= c o f a 0 , comparing t he c o e f f i c i e n t s
16 Wn=s q r t ( c o f a 0 )
17 Wn=db l (Wn) ;
18 d i s p (Wn, ” n a t u r a l f r e q u e n c y Wn=” ) // Wn=
natural frequency
19 // c o f a 1 =2∗ z e t a ∗Wn
20 // z e t a=c o f a 1 /(2∗Wn)
21 zeta =0.56;
22 k=(8∗ z e t a ) −1.2
23 d i s p ( k , ”K=” )
24 Wd=Wn∗ s q r t (1− z e t a ˆ 2) ;
25 d i s p (Wd, ”Wd=” )
26 Tp=%pi/Wd;
27 d i s p (Tp , ”Tp=” )
28 Mp=100∗ exp ((−%pi∗ z e t a ) / s q r t (1− z e t a ˆ 2) ) ;
29 d i s p (Mp, ”Mp=” )
30 Ts=4/( z e t a ∗Wn) ;
31 d i s p ( Ts , ”Ts=” )

53
Chapter 10

Stability

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox.
You can also refer the inbuilt function(routh-t) for generating Routh Ta-
ble.

10.1 Scilab Code


Example 10.02-01 10.02.01.sci

1 s = poly ( 0 , ” s ” ) ;
2 p=poly ( [ 1 2 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 q=poly ( [ 0 2 4 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
4 G=p/q ;
5 H=poly ( [ 0 . 5 ] , ’ s ’ , ’ c o e f f ’ ) ;
6 // c h a r a c t e r i s t i c equation is 1+G ( s ) H ( s ) =0
7 y=1+G∗H
8 r=numer( y )
9 disp ( ’=0 ’ , r , ” c h a r a c t e r i s t i c s e q u a t i o n i s ” )

Example 10.02-02 10.02.02.sci

1 s = poly ( 0 , ” s ” ) ;
2 p=poly ( [ 7 ] , ’ s ’ , ’ c o e f f ’ ) ;
3 q=poly ( [ 2 3 1 ] , ’ s ’ , ’ c o e f f ’ ) ;

54
4 G=p/q ;
5 H=poly ( [ 0 1 ] , ’ s ’ , ’ c o e f f ’ ) ;
6 // c h a r a c t e r i s t i c equation is 1+G ( s ) H ( s ) =0
7 y=1+G∗H
8 r=numer( y )
9 disp ( ’=0 ’ , r , ” c h a r a c t e r i s t i c s e q u a t i o n i s ” )

Example 10.02-03 10.02.03.sci

1 s = poly ( 0 , ” s ” ) ;
2 G=s y s l i n ( ’ c ’ , 2 / ( s ˆ2+2∗ s ) )
3 H=s y s l i n ( ’ c ’ , 1 / s ) ;
4 // c h a r a c t e r i s t i c equation is 1+G ( s ) H ( s ) =0
5 y=1+G∗H
6 r=numer( y )
7 disp ( ’=0 ’ , r , ” c h a r a c t e r i s t i c s e q u a t i o n i s ” )

Example 10.03 10.03.sci

1 s=%s ;
2 m=s ˆ3+5∗ s ˆ2+10∗ s +3;
3 r=c o e f f (m)
4 n=length ( r ) ;
5 r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;
6 r outh =[ routh ;−det ( routh ) / routh ( 2 , 1 ) , 0 ] ;
7 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e sub block of
routh matrix
8 r outh =[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]
9 c =0;
10 for i =1:n
11 i f ( routh ( i , 1 )< 0 )
12 c=c +1;
13 end
14 end
15 i f ( c>=1)
16 p r i n t f ( ” system i s u n s t a b l e ” )
17 e l s e ( ” system i s s t a b l e ” )
18 end

55
Example 10.04 10.04.sci

1 s=%s ;
2 m=s ˆ3+2∗ s ˆ2+3∗ s +10;
3 r=c o e f f (m)
4 n=length ( r ) ;
5 r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;
6 r outh =[ routh ;−det ( routh ) / routh ( 2 , 1 ) , 0 ] ;
7 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e sub block of
routh matrix
8 r outh =[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]
9 c =0;
10 for i =1:n
11 i f ( routh ( i , 1 ) <0)
12 c=c +1;
13 end
14 end
15 i f ( c>=1)
16 p r i n t f ( ” system i s u n s t a b l e ” )
17 e l s e ( ” system i s s t a b l e ” )
18 end

Example 10.05-01 10.05.01.sci

1 i eee ( 2 )
2 s=%s ;
3 m=s ˆ4+6∗ s ˆ3+21∗ s ˆ2+36∗ s +20
4 r=c o e f f (m)
5 n=length ( r ) ;
6 r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]
7 r outh =[ routh ;−det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,−det ( routh
( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ;
8 r outh =[ routh ;−det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,−det ( routh
( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ;
9 r outh =[ routh ;−det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ] ;
10 disp ( routh , ” routh=” )

56
11 c =0;
12 for i =1:n
13 i f ( routh ( i , 1 ) <0)
14 c=c +1;
15 end
16 end
17 i f ( c>=1)
18 p r i n t f ( ” system i s u n s t a b l e ” )
19 e l s e ( ” system i s s t a b l e ” )
20 end

Example 10.05-02 10.05.02.sci

1 s=%s ;
2 m=s ˆ5+6∗ s ˆ4+3∗ s ˆ3+2∗ s ˆ2+ s+1
3 r=c o e f f (m)
4 n=length ( r )
5 r outh =[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ]
6 r outh =[ routh ;−det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,−det ( routh
( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ]
7 r outh =[ routh ;−det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,−det ( routh
( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ]
8 r outh =[ routh ;−det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) ,−det ( routh
( 3 : 4 , 2 : 3 ) ) / routh ( 4 , 2 ) , 0 ]
9 r outh =[ routh ;−det ( routh ( 4 : 5 , 1 : 2 ) ) / routh ( 5 , 1 ) , 0 , 0 ]
10 c =0;
11 for i =1:n
12 i f ( routh ( i , 1 ) <0)
13 c=c +1;
14 end
15 end
16 i f ( c>=1)
17 p r i n t f ( ” system i s u n s t a b l e ” )
18 e l s e ( ” system i s s t a b l e ” )
19 end

Example 10.06 10.06.sci

57
1 i eee ( 2 )
2 s=%s ;
3 m=s ˆ5+2∗ s ˆ4+4∗ s ˆ3+8∗ s ˆ2+3∗ s+1
4 r=c o e f f (m) ; / / E x t r a c t s t h e c o e f f i c i e n t of the
polynomial
5 n=length ( r ) ;
6 r outh =[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ]
7 syms eps ;
8 r outh =[ routh ; eps ,−det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ;
9 r outh =[ routh ;−det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,−det ( routh
( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ;
10 r outh =[ routh ;−det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) ,−det ( routh
( 3 : 4 , 2 : 3 ) ) / routh ( 4 , 2 ) , 0 ] ;
11 r outh =[ routh ;−det ( routh ( 4 : 5 , 1 : 2 ) ) / routh ( 5 , 1 ) , 0 , 0 ] ;
12 disp ( routh , ” routh=” )
13 / / To check the s t a b i l i t y
14 r outh ( 4 , 1 )=8− l i m i t ( 5/ eps , eps , 0 ) ; // P u t t i n g the value of
e p s =0 in routh (4 ,1)
15 disp ( routh ( 4 , 1 ) , ” routh ( 4 , 1 )=” )
16 r outh ( 5 , 1 )= l i m i t ( routh ( 5 , 1 ) , eps , 0 ) ; // P u t t i n g the
value of e p s =0 in routh (5 ,1)
17 disp ( routh ( 5 , 1 ) , ” routh ( 5 , 1 ) = ’)
18 r outh
19 p r i n t f ( ” There a r e two sign changes o f f i r s t column ,
hence t h e system i s u n s t a b l e \n” )

Example 10.07 10.07.sci

1 s=%s ;
2 m=s ˆ5+2∗ s ˆ4+2∗ s ˆ3+4∗ s ˆ2+4∗ s+8
3 r outh=routh t (m) / / T h i s F u n c t i o n generates the Routh
table
4 c =0;
5 for i =1:n
6 i f ( routh ( i , 1 ) <0)
7 c=c +1;
8 end
9 end

58
10 i f ( c>=1)
11 p r i n t f ( ” system i s u n s t a b l e ” )
12 e l s e ( ” system i s s t a b l e ” )
13 end

Example 10.08 10.08.sci

1 s=%s ;
2 m=s ˆ4+5∗ s ˆ3+2∗ s ˆ2+3∗ s+2
3 r=c o e f f (m)
4 n=length ( r ) ;
5 r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]
6 r outh =[ routh ;−det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,−det ( routh
( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ;
7 r outh =[ routh ;−det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,−det ( routh
( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ;
8 r outh =[ routh ;−det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ]
9 c =0;
10 for i =1:n
11 i f ( routh ( i , 1 ) <0)
12 c=c +1;
13 end
14 end
15 i f ( c>=1)
16 p r i n t f ( ” system i s u n s t a b l e ” )
17 e l s e ( ” system i s s t a b l e ” )
18 end

Example 10.09 10.09.sci

1 i eee ( 2 ) ;
2 s=%s ;
3 m=s ˆ5+ s ˆ4+3∗ s ˆ3+3∗ s ˆ2+4∗ s+8
4 r=c o e f f (m) ; / / E x t r a c t s t h e c o e f f i c i e n t of the
polynomial
5 n=length ( r ) ;
6 r outh =[ r ( [ 6 , 4 , 2 ] ) ; r ( [ 5 , 3 , 1 ] ) ]
7 syms eps ;

59
8 r outh =[ routh ; eps ,−det ( routh ( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ;
9 r outh =[ routh ;−det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,−det ( routh
( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ;
10 r outh =[ routh ;−det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) ,−det ( routh
( 3 : 4 , 2 : 3 ) ) / routh ( 4 , 2 ) , 0 ] ;
11 r outh =[ routh ;−det ( routh ( 4 : 5 , 1 : 2 ) ) / routh ( 5 , 1 ) , 0 , 0 ] ;
12 disp ( routh , ” routh=” )
13 / / To check the s t a b i l i t y
14 r outh ( 4 , 1 )=l i m i t ( routh ( 4 , 1 ) , eps , 0 ) ; // P u t t i n g the value
of e p s =0 in routh (4 ,1)
15 disp ( routh ( 4 , 1 ) , ” routh ( 4 , 1 )=” )
16 r outh ( 5 , 1 )= l i m i t ( routh ( 5 , 1 ) , eps , 0 ) ; // P u t t i n g the
value of e p s =0 in routh (5 ,1)
17 disp ( routh ( 5 , 1 ) , ” routh ( 5 , 1 ) = ’)
18 r outh
19 p r i n t f ( ” There a r e two sign changes o f f i r s t column ,
hence t h e system i s u n s t a b l e \n” )

Example 10.10 10.10.sci

1 i eee ( 2 ) ;
2 syms s k ;
3 m=s ˆ4+4∗ s ˆ3+7∗ s ˆ2+6∗ s+k ;
4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;
5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;
6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;
7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;
8 c o f a 4 = c o e f f s (m, ’ s ’ , 4 ) ;
9

10 r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 cof a 4 ]
11

12 n=length ( r ) ;
13 r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]
14 r outh =[ routh ;−det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,−det ( routh
( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ;
15 r outh =[ routh ;−det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,−det ( routh
( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ;
16 r outh =[ routh ;−det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ] ;

60
17 disp ( routh , ” routh=” )

Example 10.11 10.11.sci

1 i eee ( 2 ) ;
2 syms s k ;
3 m=(24/100) ∗ s ˆ3+ s ˆ2+ s+k ;
4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;
5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;
6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;
7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;
8 r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]
9 n=length ( r ) ;
10 r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ]
11 r outh =[ routh ;−det ( routh ) / routh ( 2 , 1 ) , 0 ]
12 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e sub block of
routh matrix
13 r outh =[ routh ;−det ( t ) / routh ( 3 , 1 ) , 0 ]
14 disp ( routh , ” routh=” ) ;
15 r outh ( 3 , 1 ) =0 / / F o r m a r g i n a l y s t a b l e s y s t e m
16 k =1/0.24;
17 disp ( k , ”K( m a r g i n a l )=” )
18 disp ( ’=0 ’ , ( s ˆ 2)+k , ” a u x i l l a r y e q u a t i o n ” )
19 s=sqrt(−k ) ;
20 disp ( s , ” Frequency o f o s c i l l a t i o n ( i n rad / s e c )=” )

Example 10.12 10.12.sci

1 i eee ( 2 ) ;
2 syms p K s ;
3 m=s ˆ3+(p∗ s ˆ 2 ) +(K+3)∗ s +(2∗(K+1) )
4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;
5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;
6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;
7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;
8 r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]
9 n=length ( r ) ;
10 r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;

61
11 r outh =[ routh ;−det ( routh ) / routh ( 2 , 1 ) , 0 ] ;
12 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e sub block of
routh matrix
13 r outh =[ routh ;−det ( t ) / routh ( 3 , 1 ) , 0 ] ;
14 disp ( routh , ” routh=” )

Example 10.13 10.13.sci

1 i eee ( 2 ) ;
2 s=%s ;
3 m=2∗ s ˆ4+(4∗ s ˆ 2)+1
4 r outh=routh t (m) // G e n e r a t e s the Routh Table
5 roots (m) // G i v e s the Roots of the Polynomial
(m)
6 disp ( 0 , ” th e number o f r o o t s l y i n g i n th e l e f t h a l f
plane of s−p l a n e=” )
7 disp ( 0 , ” th e number o f r o o t s l y i n g i n th e r i g h t h a l f
plane of s−p l a n e=” )
8 disp ( 4 , ” th e number o f r o o t s l y i n g on t he i m a g i n a r y a x i s
=” )

Example 10.14 10.14.sci

1 i eee ( 2 ) ;
2 syms s k ;
3 m=s ˆ4+6∗ s ˆ3+10∗ s ˆ2+8∗ s+k ;
4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;
5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;
6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;
7 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;
8 c o f a 4 = c o e f f s (m, ’ s ’ , 4 ) ;
9 r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 c o f a 4 ]
10 n=length ( r ) ;
11 r outh =[ r ( [ 5 , 3 , 1 ] ) ; r ( [ 4 , 2 ] ) , 0 ]
12 r outh =[ routh ;−det ( routh ( 1 : 2 , 1 : 2 ) ) / routh ( 2 , 1 ) ,−det ( routh
( 1 : 2 , 2 : 3 ) ) / routh ( 2 , 2 ) , 0 ] ;
13 r outh =[ routh ;−det ( routh ( 2 : 3 , 1 : 2 ) ) / routh ( 3 , 1 ) ,−det ( routh
( 2 : 3 , 2 : 3 ) ) / routh ( 3 , 2 ) , 0 ] ;

62
14 r outh =[ routh ;−det ( routh ( 3 : 4 , 1 : 2 ) ) / routh ( 4 , 1 ) , 0 , 0 ] ;
15 disp ( routh , ” routh=” )

Example 10.15 10.15.sci

1 i eee ( 2 ) ;
2 syms s T;
3 m=s ˆ2+(2−T) ∗ s+1
4 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;
5 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;
6 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;
7 r =[ c o f a 0 c o f a 1 c o f a 2 ]
8 n=length ( r ) ;
9 r outh =[ r ( [ 3 , 1 ] ) ; r ( 2 ) , 0 ] ;
10 r outh =[ routh ;−det ( routh ) / routh ( 2 , 1 ) , 0 ] ;
11 disp ( routh , ” routh=” )

Example 10.16 10.16.sci

1 i eee ( 2 )
2 s=%s ;
3 m=s ˆ6+2∗ s ˆ5+7∗ s ˆ4+10∗ s ˆ3+14∗ s ˆ2+8∗ s+8
4 r outh=routh t (m) ;
5 disp ( routh , ” routh=” )
6 c =0;
7 for i =1:n
8 i f ( routh ( i , 1 ) <0)
9 c=c +1;
10 end
11 end
12 i f ( c>=1)
13 p r i n t f ( ” system i s u n s t a b l e ” )
14 e l s e ( ” system i s s t a b l e ” )
15 end

63
Chapter 11

Root Locus Method

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox
When we will execute the programm we will get the following Graphs

11.1 Scilab Code


Example 11.01 11.01.sci

1 s=%s ;
2 s y s 1=s y s l i n ( ’ c ’ , 1 / ( s +1) ) ;
3 evans ( sys1 , 2 0 0 )
4 p r i n t f ( ” I f k i s v a r i e d from 0 t o any v a l u e , r o o t l o c u s
v a r i e s from −k t o 0 \n ” )

Example 11.02 11.02.sci

1 s=%s ;
2 s y s 1=s y s l i n ( ’ c ’ , ( s +1) / ( s +4) ) ;
3 evans ( sys1 , 1 0 0 )
4 p r i n t f ( ” r o o t l o c u s b e g i n s a t s=−4 & ends a t s=−1” )

Example 11.03 11.03.sci

64
Figure 11.1: Output Graph of S 11.01

1 s=%s ;
2 s y s 1=s y s l i n ( ’ c ’ , ( s+3−%i ) ∗( s+3+%i ) / ( ( s+2−%i ) ∗( s+2+%i ) ) ) ;
3 evans ( sys1 , 1 0 0 )
4 p r i n t f ( ” R o o t l o c u s s t a r t s from s=−2+i & −2− i ends a t s
=−3+i &−3− i \n” )

Example 11.04 11.04.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( s +1) / ( s +2) ) ;
3 evans (H, 1 0 0 )

65
Figure 11.2: Output Graph of S 11.02

4 p r i n t f ( ” C l e a r l y from th e graph i t o b s e r v e d t h a t g i v e n
p o i n t −1+ i & −3+ i does not l i e on th e r o o t l o c u s \n
”)
5 // there is another process to check whether the points
lie on the locus of the system
6 P=−1+%i ; / / P= s e l e c t e d point
7 k1=−1/r e a l ( horner (H, P) )
8 Ns=H( ’num ’ ) ; Ds=H( ’ den ’ ) ;
9 roots ( Ds+k1∗Ns ) // do es not contains P as particular
root
10 P=−3+%i ; / / P= s e l e c t e d point
11 k2=−1/r e a l ( horner (H, P) ) ;

66
Figure 11.3: Output Graph of S 11.03

12 Ns=H( ’num ’ ) ; Ds=H( ’ den ’ )


13 roots ( Ds+k2∗Ns ) // do es not contains P as particular
root

Example 11.05 11.05.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( s ∗( s +1) ∗( s +3) ) ) ;
3 evans (H, 1 0 0 )
4 p r i n t f ( ” C l e a r l y from t he graph i t o b s e r v e d t h a t g i v e n
p o i n t −0.85 l i e s on t he r o o t l o c u s \n” )

67
Figure 11.4: Output of S 11.04

5 // there is another process to check whether the points


lie on the locus of the system
6 P= −0.85; / / P= s e l e c t e d point
7 k=−1/r e a l ( horner (H, P) ) ;
8 disp ( k , ”k = ’)
9 Ns=H( ’ num ’ ) ; Ds=H( ’ den ’ ) ;
10 r o o t s ( Ds+k∗Ns ) // c o n t a i n s P as p a r t i c u l a r r o o t

68
Figure 11.5: Output of S 11.05

Example 11.06 11.06.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s +1) ∗( s +5) ) ) ;
3 evans (H, 1 0 0 )
4 p r i n t f ( ” C l e a r l y from t he graph i t o b s e r v e d t h a t g i v e n
p o i n t −0.85 l i e s on t he r o o t l o c u s \n” )
5 // there is another process to check whether the points
lie on the locus of the system
6 P=−3+5∗%i ; / / P= s e l e c t e d point
7 k=−1/r e a l ( horner (H, P) ) ;
8 disp ( k , ”k = ’)

69
Figure 11.6: Output of S 11.06

9 Ns=H( ’ num ’ ) ; Ds=H( ’ den ’ ) ;


10 r o o t s ( Ds+k∗Ns ) // c o n t a i n s P as p a r t i c u l a r r o o t

Example 11.08 11.08.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( s +2) / ( ( s +1)∗ s ∗( s +4) ) ) ;
3 evans (H, 1 0 0 )
4 p r i n t f ( ”From t he graph we o b s e r v e d that , \n a ) The no o f
l o c i ending a t i n f i s 2 \n b ) Three l o c i w i l l s t a r t
from s= 0,−1 & −4,\n c ) One l o c i w i l l end a t −2 &

70
Figure 11.7: Output of S 11.08

r e m a i n i n g two w i l l end a t i n f ” )

Example 11.09 11.09.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( s +2) / ( ( s +1)∗ s ∗( s +4) ) ) ;
3 evans (H, 1 0 0 )

Example 11.10 11.10.sci

1 n=3;

71
Figure 11.8: Output of S 11.09

2 disp ( n , ”no o f p o l e s=” )


3 m=1;
4 disp (m, ”no o f p o l e s=” )
5 q=0;
6 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
7 disp (O, ”q=” )
8 q=1;
9 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
10 disp (O, ”q=” )
11

12 p r i n t f ( ” C e n t r o i d =((sum o f a l l r e a l p a r t o f p o l e s o f G( s
)H( s ) ) −(sum o f a l l r e a l p a r t o f z e r o s o f G( s )H( s ) ) / (

72
n−m) \n” )
13 C=((0−1−4)−(−2) ) / 2 ;
14 disp (C, ” c e n t r o i d=” )

Example 11.11 11.11.sci

1 n=3;
2 disp ( n , ”no o f p o l e s=” )
3 m=0;
4 disp (m, ”no o f p o l e s=” )
5 q=0;
6 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
7 disp (O, ”q=” )
8 q=1;
9 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
10 disp (O, ”q=” )
11 q=2;
12 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
13 disp (O, ”q=” )
14

15 p r i n t f ( ” C e n t r o i d =((sum o f a l l r e a l p a r t o f p o l e s o f G( s
)H( s ) ) −(sum o f a l l r e a l p a r t o f z e r o s o f G( s )H( s ) ) / (
n−m) \n” )
16 C=((0−1−1)−(−0) ) / 3 ;
17 disp (C, ” c e n t r o i d=” )

Example 11.12 11.12.sci

1 n=4;
2 disp ( n , ”no o f p o l e s=” )
3 m=1;
4 disp (m, ”no o f p o l e s=” )
5 q=0;
6 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
7 disp (O, ”q=” )
8 q=1;
9 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
10 disp (O, ”q=” )

73
11 q=2;
12 O=((2∗ q ) +1) / ( n−m) ∗ 1 8 0 ;
13 disp (O, ”q=” )
14

15 p r i n t f ( ” C e n t r o i d =((sum o f a l l r e a l p a r t o f p o l e s o f G( s
)H( s ) ) −(sum o f a l l r e a l p a r t o f z e r o s o f G( s )H( s ) ) / (
n−m) \n” )
16 C=((0−2−4−5)−(−3) ) / 3 ;
17 disp (C, ” c e n t r o i d=” )

Example 11.13 11.13.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( s +2) / ( ( s +1)∗ s ∗( s +3) ) ) ;
3 plzr (H)
4 p r i n t f ( ” There a r e two a d j a c e n t p l a c e d p o l e s a t s=0 &s
=−1 \n” )
5 p r i n t f ( ”One breakaway p o i n t e x i s t s between s=0 & s=−1 \
n” )

Example 11.14 11.14.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( ( s +2) ∗( s +4) ) / ( ( s ˆ2 ) ∗( s +5) ) ) ;
3 plzr (H)
4 p r i n t f ( ” There a r e two a d j a c e n t p l a c e d z e r o s a t s=−2 &s
=−4 \n” )
5 p r i n t f ( ”One b r e a k i n p o i n t e x i s t s between s=−2 & s=−4 \n
”)

Example 11.15 11.15.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( s +6) / ( ( s +1) ∗( s +3) ) ) ;
3 plzr (H)
4 p r i n t f ( ” There a r e two a d j a c e n t p l a c e d p o l e s a t s=−3 &s
=−1 \n” )

74
Figure 11.9: Output of S 11.13

5 p r i n t f ( ”One breakaway p o i n t e x i s t s between s=−3 & s=−1


\n” )
6 p r i n t f ( ”One b r e a k i n p o i n t e x i s t s t o th e l e f t o f z e r o s
a t s=−6 \n” )

Example 11.16 11.16.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s +1)∗ s ∗( s +3) ) ) ;
3 plzr (H)
4 p r i n t f ( ” There a r e two a d j a c e n t p l a c e d p o l e s a t s=0 &s

75
Figure 11.10: Output of S 11.14

=−1 \n” )
5 p r i n t f ( ”One breakaway p o i n t e x i s t s between s=0 & s=−1
\n” )

Example 11.17 11.17.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s +1)∗ s ∗( s +3) ) ) ;
3 evans (H, 1 0 0 )
4 syms k ;
5 m=s ˆ3+6∗ s ˆ2+8∗ s+k ;

76
Figure 11.11: Output of S 11.15

6 c o f a 0 = c o e f f s (m, ’ s ’ , 0 ) ;
7 c o f a 1 = c o e f f s (m, ’ s ’ , 1 ) ;
8 c o f a 2 = c o e f f s (m, ’ s ’ , 2 ) ;
9 c o f a 3 = c o e f f s (m, ’ s ’ , 3 ) ;
10 r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]
11

12 n=length ( r ) ;
13 r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;
14 r outh =[ routh ;−det ( routh ) / routh ( 2 , 1 ) , 0 ] ;
15 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e sub block of
routh matrix
16 r outh =[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]

77
Figure 11.12: Output of S 11.16

17 disp ( 4 8 , ”K( m a r g i n a l )=” )


18 disp ( ’=0 ’ , ( 6 ∗ s ˆ 2 )+k , ” a u x i l l a r y e q u a t i o n ” )
19 k =48;
20 s=sqrt(−k / 6) ;
21 disp ( s , ” s=” )

Example 11.19 11.19.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s+1+%i ) ∗ s ∗( s+1−%i ) ) ) ;
3 evans (H, 1 0 0 )

78
Figure 11.13: Output of S 11.17

Example 11.20 11.20.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s +3)∗ s ∗( s +5) ) ) ;
3 evans (H, 1 0 0 )

Example 11.21 11.21.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s+2+%i ) ∗( s +1) ∗( s+2−%i ) ) ) ;
3 evans (H, 1 0 0 )

79
Figure 11.14: Output of S 11.19

Example 11.22 11.22.sci

1 s=%s ;
2 num=r e a l ( poly ( [ 1 ] , ’ s ’ , ” c o e f f ” ) )
3 den=r e a l ( poly([−1,−2+%i,−2−%i ] , ’ s ’ ) )
4 H=num/ den
5 evans (H, 1 0 0 )
6 k =1.5;
7 disp ( k , ”K( d e s i g n )=” )
8 // Kpure calculates the value of k at imaginary
crossover
9 [ K,Y]=kpure (H)

80
Figure 11.15: Output of S 11.20

10 GM=K/k ;
11 disp (GM, ” v a l u e o f k a t i m a g i n a r y c r o s s o v e r /k ( d e s i g n )=”
)
12 disp (GM, ” g a i n margin=” )

Example 11.23 11.23.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( s ∗ ( ( s +3) ˆ2 ) ) ) ;
3 evans (H, 1 0 0 )
4 K=25;

81
Figure 11.16: Output of S 11.21

5 y=K∗H; / / −−−−− e q 1 )
6 disp (K∗H, ”G( s )H( s )=” ) ;
7 disp ( ’=1 ’ ,K∗H, ”mod(G( s )H( s ) ) ” ) ;
8 // on solving eq 1 for s =%i ∗w this we get an equation m
9 w=poly ( 0 , ’w ’ ) ;
10 m=wˆ3+9∗w−25
11 n=roots (m)
12 s=%i∗n ( 1 )
13 p=horner ( y , s )
14 [ R, Theta ]= polar ( p )
15 PM=180+Theta

82
Figure 11.17: Output of S 11.22

Example 11.25 11.25.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s +1)∗ s ∗( s +2) ∗( s +4) ) ) ;
3 evans (H, 1 0 0 )

Example 11.26 11.26.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , ( s +4) ∗( s +5) / ( ( s +1) ∗( s +3) ) ) ;
3 evans (H, 1 0 0 )

83
Figure 11.18: Output of S 11.23

Example 11.27 11.27.sci

1 s=%s ;
2 syms k Wn;
3 H=s y s l i n ( ’ c ’ , 1 / ( ( s +3) ˆ2∗ s ) ) ;
4 evans (H, 1 0 0 ) / / r o o t l o c u s
5 p r i n t f ( ”To d e t e r m i n e t h e v a l u e o f Wn \n” )
6 disp ( k∗H, ”G( s )H( s )=” )
7 y=1+(k∗H) ;
8 disp ( ’=0 ’ , y , ”1+G( s )H( s ) ” )
9 evans (H, 1 0 0 )

84
Figure 11.19: Output of S 11.25

10 [ num , den ]=numden ( y )


11

12 c o f a 0 = c o e f f s (num , ’ s ’ , 0 ) ;
13 c o f a 1 = c o e f f s (num , ’ s ’ , 1 ) ;
14 c o f a 2 = c o e f f s (num , ’ s ’ , 2 ) ;
15 c o f a 3 = c o e f f s (num , ’ s ’ , 3 ) ;
16 r =[ c o f a 0 c o f a 1 c o f a 2 c o f a 3 ]
17

18 n=length ( r ) ;
19 r outh =[ r ( [ 4 , 2 ] ) ; r ( [ 3 , 1 ] ) ] ;
20 r outh =[ routh ;−det ( routh ) / routh ( 2 , 1 ) , 0 ] ;
21 t=routh ( 2 : 3 , 1 : 2 ) ; / / e x t r a c t i n g t h e s q u a r e sub block of

85
Figure 11.20: Output of S 11.26

routh matrix
22 r outh =[ routh ;−det ( t ) / t ( 2 , 1 ) , 0 ]
23 // to obtain Wn
24 disp ( ’=0 ’ , ( ( 6 ∗ s ˆ 2) +54) , ” a u x i l l a r y eq ” )
25 p=(6∗( s ˆ2 ) )+k ;
26 s=%i∗Wn
27 k =54;
28 p=eval ( p )
29 Wn=sqrt ( k /6 )
30 p r i n t f ( ”With gvn v a l u e s o f z e t a adding a g r i d on r o o t
l o c u s \n” )
31

86
32 zeta =0.5; / / g i v e n
33 sgrid ( z e t a ,Wn, 7 ) // add a grid over an existing
continuous s−plane root with given values for zeta
and wn .
34 p r i n t f ( ”NOTE:− c l i c k on th e p o i n t where l o c u s i n t e r s e c t s
z =0.5 f o r d e s i r e d v a l u e o f k \n” )
35 k=−1/r e a l ( horner (H, [ 1 , %i ] ∗ locate ( 1 ) ) ) / / T o o b t a i n t h e
gain at a given point of the locus
36

37

38 p=locate ( 1 ) // d e s i r e d point on the root locus

Example 11.28 11.28.sci

1 s=%s ;
2 H=s y s l i n ( ’ c ’ , 1 / ( ( s +4)∗ s ∗( s +6) ) ) ;
3 evans (H, 1 0 0 )

87
Figure 11.21: Output of S 11.27

88
Figure 11.22: Output of S 11.28

89
Chapter 12

Frequency Domain Analysis

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox.

12.1 Scilab Code


Example 12.01 12.01.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s a s polynomial variable


2 F=s y s l i n ( ’ c ’ , [ 2 2 5 / ( ( s +6)∗ s ) ] ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 CL=F / .B // C a l c u l a t e s closed −loop transfer function
5 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
6 y=denom(CL) // e x t r a c t i n g the denominator of CL
7 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
8 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
9 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
10 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
11 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
12 Mr=1/(2∗ z e t a ∗ sqrt (1− z e t a ˆ 2) )
13 Wr=Wn∗ sqrt (1− z e t a ˆ 2)
14 Wc=Wn∗ sqrt ((1 −2∗ z e t a ˆ 2)+sqrt (4∗ z e t a ˆ4−4∗ z e t a ˆ2+2) )

90
15 BW=Wc / / BANDWIDTH

Example 12.02 12.02.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s a s polynomial variable


2 F=s y s l i n ( ’ c ’ , [ 3 6 / ( ( s +8)∗ s ) ] ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 CL=F / .B // C a l c u l a t e s closed −loop transfer function
5 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
6 y=denom(CL) // e x t r a c t i n g the denominator of CL
7 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
8 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
9 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
10 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
11 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
12 Mr=1/(2∗ z e t a ∗ sqrt (1− z e t a ˆ 2) )
13 Wr=Wn∗ sqrt (1− z e t a ˆ 2)
14 Wc=Wn∗ sqrt ((1 −2∗ z e t a ˆ 2)+sqrt (4∗ z e t a ˆ4−4∗ z e t a ˆ2+2) )
15 BW=Wc / / BANDWIDTH

Example 12.03 12.03.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s a s polynomial variable


2 F=s y s l i n ( ’ c ’ , [ 8 1 / ( s ˆ2+7∗ s ) ] ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 CL=F / .B // C a l c u l a t e s closed −loop transfer function
5 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
6 y=denom(CL) // e x t r a c t i n g the denominator of CL
7 z=c o e f f ( y ) // e x t r a c t i n g the c o e f f i c i e n t s of the
denominator polynomial
8 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
9 Wn=sqrt ( z ( 1 , 1 ) ) // Wn= n a t u r a l frequency
10 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )

91
11 z e t a=z ( 1 , 2 ) /(2∗Wn) // z e t a =damping factor
12 Mr=1/(2∗ z e t a ∗ sqrt (1− z e t a ˆ 2) )
13 Wr=Wn∗ sqrt (1− z e t a ˆ 2)
14 Wc=Wn∗ sqrt ((1 −2∗ z e t a ˆ 2)+sqrt (4∗ z e t a ˆ4−4∗ z e t a ˆ2+2) )
15 BW=Wc / / BANDWIDTH

Example 12.04 12.04.sci

1 // D e f i n e s s as polynomial variable
2 s=poly ( 0 , ’ s ’ ) ;
3 // C r e a t e s transfer function in forward path
4 F=s y s l i n ( ’ c ’ , [ 8 1 / ( ( s +18)∗ s ) ] ) ;
5 // C r e a t e s transfer function in backward path
6 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ;
7 // C a l c u l a t e s closed −loop transfer function
8 CL=F / .B
9 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
10 y=denom(CL) / / extracting the denominator of CL
11 // E x t r a c t i n g the c o e f f i c i e n t s of the denominator
polynomial
12 z=c o e f f ( y )
13 / / Wn ˆ 2 = z ( 1 , 1 ) , comparing the c o e f f i c i e n t s
14 Wn=sqrt ( z ( 1 , 1 ) )
15 / / 2 ∗ z e t a ∗ Wn= z ( 1 , 2 )
16 z e t a=z ( 1 , 2 ) /(2∗Wn)
17 // zeta =damping factor
18 / / NOTE = here s q r t (1 −2 z e t a ˆ 2 ) becomes complex so the
other solution is Wr = 0 & Mr =1
19 Mr=1
20 Wr=0
21 Wc=Wn∗((1 −2∗ z e t a ˆ 2)+sqrt (4∗ z e t a ˆ4−4∗ z e t a ˆ2+2) )
22 BW=Wc / / BANDWIDTH

Example 12.05 12.05.sci

1 i eee ( 2 ) ;
2 syms k a ;
3 num=k ;

92
4 den=s ∗( a+s ) ;
5 G=num/ den ;
6 disp (G, ”G( s )=” )
7 H=1;
8 CL=G/ .H;
9 CL=s i m p l e (CL) ;
10 disp (CL, ”C( s ) /R( s )=” ) // C a l c u l a t e s closed −loop
transfer function
11 // compare CL with Wn ˆ 2 / ( s ˆ 2 + 2 ∗ z e t a ∗ Wn+Wn ˆ 2 )
12 [ num , den ]=numden (CL) ; // e x t r a c t s num & den of symbolic
function ( CL )
13 c o f a 0 = c o e f f s ( den , ’ s ’ , 0 ) ; // coeff of den of
symbolic function ( CL )
14 c o f a 1 = c o e f f s ( den , ’ s ’ , 1 ) ;
15 / / Wn ˆ 2 = cof a 0 , comparing the c o e f f i c i e n t s
16 Wn=sqrt ( c o f a 0 )
17 // c o f a 1 = 2 ∗ z e t a ∗ Wn
18 z e t a=c o f a 1 /(2∗Wn)
19 Mr=1/(2∗ z e t a ∗ sqrt (1− z e t a ˆ 2) ) / / − − − − − − − − − −1)
20 p r i n t f ( ” Given ,Mr=1.25 \n” ) ;
21 / / On solving eq (1) we get k = 1 . 2 5 a ˆ2 − − − − − − −2
22 p r i n t f ( ”k =1.25∗ a ˆ2 \n” )
23 Wr=Wn∗ sqrt (1−2∗ z e t a ˆ 2) / / −− −− −− −− −−− −− −−3)
24 p r i n t f ( ” Given , Wr=12.65 \n” ) ;
25 // on soving eq ( 3 ) , we get 2 k − a ˆ2=320 − − − − − − − − − − −4)
26 p r i n t f ( ”2k−aˆ2=320 \n” )
27 // now eq 2 &4 can be simultaneously soved to take out
values of k &a
28 // Let k=x & a ˆ2= y
29 A= [ 1 , − 1 . 2 5 ; 2 , − 1 ] ; // c o e f f i c i e n t matrix
30 b=[0;320];
31 m=A\b ;
32 x=m( 1 , 1 ) ;
33 k=x
34 y=m( 2 , 1 ) ;
35 a=sqrt ( y )
36 Wn=db l ( eval (Wn) ) ;
37 disp (Wn, ”Wn=” )

93
38 z e t a=db l ( eval ( z e t a ) ) ;
39 disp ( z e t a , ” z e t a = ’)
40 Ts=4/( z e t a ∗Wn) ;
41 d i s p ( Ts , ” S e t t l i n g Time ( Ts )=” )
42 Wc=Wn((1 −(2∗ z e t a ˆ 2) )+s q r t (4∗ z e t a ˆ4−4∗ z e t a ˆ2+2) )
43 d i s p (Wc, ”BW=” )

94
Chapter 13

Bode Plot

When we will execute the programm we will get the following Graphs.

13.1 Scilab Code


Example 13.01 13.01.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s as polynomial variable


2 F=s y s l i n ( ’ c ’ , [ 2 0 / ( s +2) ] ) // C r e a t e s transfer function in
forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) // C r e a t e s transfer
function in backward path
4 OL=F∗B / / C a l c u l a t e s open − l o o p transfer function
5 fmin = 0 . 1 ; / / M i n f r e q in Hz
6 fmax =100; / / M a x f r e q in Hz
7 scf (1) ; c l f ;
8 bode (OL, fmin , fmax ) ; // P l o t s frequency response of open −
loop system in Bode diagram
9 show margins (OL) // d i s p l a y gain and phase margin and
associated crossover frequencies

Example 13.02 13.02.sci

1 s=poly ( 0 , ’ s ’ ) ; // D e f i n e s s as polynomial variable

95
Figure 13.1: Output of S 13.01

2 F=s y s l i n ( ’ c ’ , [ 2 0 / ( ( 2 + s ) ∗ s ) ] ) ; // C r e a t e s transfer
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 OL=F∗B ; / / C a l c u l a t e s o p e n − l o o p transfer function
5 fmin = 0 . 0 1 ; / / M i n f r e q i n H z
6 fmax =20; / / M a x f r e q i n H z
7 scf (1) ; c l f ;

96
Figure 13.2: Output of S 13.02

8 bode (OL, fmin , fmax ) ; // P l o t s frequency response of open −


loop system in Bode diagram
9 show margins (OL) // d i s p l a y gain and phase margin and
associated crossover frequencies

Example 13.03 13.03.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=s y s l i n ( ’ c ’ , [ 4 0 / ( ( 2 + s ) ∗ s ∗( s +5) ) ] ) / / C r e a t e s t r a n s f e r
function in forward path

97
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) // C r e a t e s transfer
function in backward path
4 OL=F∗B ; / / C a l c u l a t e s open − l o o p transfer function
5 fmin = 0 . 1 ; / / M i n f r e q in Hz
6 fmax =20; / / M a x f r e q in Hz
7 scf (1) ; c l f ;
8 bode (OL, fmin , fmax ) ; // P l o t s frequency response of open −
loop system in Bode diagram
9 [ GainMargin , freqGM]=g margin (OL) // C a l c u l a t e s gain
margin [ dB ] and corresponding frequency [ Hz ]
10 [ Phase , freqPM]=p margin (OL) // C a l c u l a t e s phase [ deg ]
and corresponding freq [ Hz ] of phase margin
11 PhaseMargin=180+Phase // C a l c u l a t e s actual phase margin
[ deg ]
12 show margins (OL) // d i s p l a y gain and phase margin and
associated crossover frequencies

Example 13.04 13.04.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=s y s l i n ( ’ c ’ , [ 4 0 / ( ( s +5)∗(2+ s ) ∗ s ˆ 2 ) ] ) / / C r e a t e s t r a n s f e r
function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) ; // C r e a t e s transfer
function in backward path
4 OL=F∗B ; / / C a l c u l a t e s open − l o o p transfer function
5 fmin = 0 . 1 ; / / M i n f r e q in Hz
6 fmax =20; / / M a x f r e q in Hz
7 scf (1) ; c l f ;
8 bode (OL, fmin , fmax ) ; // P l o t s frequency response of open −
loop system in Bode diagram
9 show margins (OL) // d i s p l a y gain and phase margin and
associated crossover frequencies

Example 13.05 13.05.sci

1 s=poly ( 0 , ’ s ’ ) ; // D e f i n e s s as polynomial variable

98
Figure 13.3: Output of S 13.03

2 F=s y s l i n ( ’ c ’ , [ ( 4 0 0 ∗ ( s +2) ) / ( ( s +5)∗(10+ s ) ∗ s ˆ 2 ) ] ) //


Creates transfer function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) // C r e a t e s transfer
function in backward path
4 OL=F∗B / / C a l c u l a t e s open − l o o p transfer function
5 fmin = 0 . 1 ; / / M i n f r e q in Hz
6 fmax =20; / / M a x f r e q in Hz
7 scf (1) ; c l f ;
8 bode (OL, fmin , fmax ) ; // P l o t s frequency response of open −
loop system in Bode diagram
9 show margins (OL) // d i s p l a y gain and phase margin and
associated crossover frequencies

99
Figure 13.4: Output of S 13.04

Example 13.06 13.06.sci

1 s=poly ( 0 , ’ s ’ ) ; / / D e f i n e s s a s p o l y n o m i a l v a r i a b l e
2 F=s y s l i n ( ’ c ’ , [ ( 2 8 8 ∗ ( s +4) ) / ( ( s +2) ∗(144+4.8∗ s+s ˆ 2 ) ∗ s ) ] )
// C r e a t e s transfer function in forward path
3 B=s y s l i n ( ’ c ’ ,(1+0∗ s ) /(1+0∗ s ) ) // C r e a t e s transfer
function in backward path
4 OL=F∗B / / Calculates open − l o o p transfer function
5 fmin = 0 . 1 ; // Min freq in Hz
6 fmax =100; / / Max freq in Hz

100
Figure 13.5: Output of S 13.05

7 scf (1) ; c l f ;
8 bode (OL, fmin , fmax ) ; // P l o t s frequency response of open −
loop system in Bode diagram
9 show margins (OL) // d i s p l a y gain and phase margin and
associated crossover frequencies

101
Figure 13.6: Output of S 13.06

102
Chapter 15

Nyquist Plot

When we will execute the programm we will get the following Graphs

15.1 Scilab Code


Example 15.01 15.01.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ , 1 / ( s +2) )
3 nyquist ( s y s )
4 show margins ( sys , ’ n y q u i s t ’ )
5 p r i n t f ( ” S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s )
\n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e
RHP i s z e r o \n hence t h e system i s s t a b l e ” )

Example 15.02 15.02.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ , 1 / ( s ∗( s +2) ) )
3 nyquist ( s y s )
4 show margins ( sys , ’ n y q u i s t ’ )
5 p r i n t f ( ” S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s )
\n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e
RHP i s z e r o \n hence t h e system i s s t a b l e ” )

103
Figure 15.1: Output of S 15.01

Example 15.03 15.03.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ , 1 / ( s ˆ2∗( s +2) ) )
3 nyquist ( s y s )
4 show margins ( sys , ’ n y q u i s t ’ )
5 p r i n t f ( ” S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s )
\n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e

104
Figure 15.2: Output of S 15.02

RHP i s not e q u a l t o z e r o \n hence t he system i s


unstable ”)

Example 15.04 15.04.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ , 1 / ( s ˆ3∗( s +2) ) )
3 nyquist ( s y s )
4 show margins ( sys , ’ n y q u i s t ’ )
5 p r i n t f ( ” S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s )
\n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e

105
Figure 15.3: Output of S 15.03

RHP i s N>0 \n hence t he system i s u n s t a b l e ” )

Example 15.05 15.05.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ , 1 / ( s ˆ2∗( s +2) ) )
3 nyquist ( s y s )
4 show margins ( sys , ’ n y q u i s t ’ )
5 p r i n t f ( ” S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s )
\n h e r e t he number o f z e r o s o f 1+G( s )H( s ) i n th e
RHP i s N>0 \n hence t he system i s u n s t a b l e ” )

106
Figure 15.4: Output of S 15.04

Example 15.06 15.06.sci

1 s=%s ;
2 P1=1;
3 P2=2;
4 s y s=s y s l i n ( ’ c ’ , 1 / ( ( s +1) ∗( s +2) ) )
5 nyquist ( s y s )
6 show margins ( sys , ’ n y q u i s t ’ )
7 p r i n t f ( ” S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s )
\n\n Here t he number o f z e r o s o f 1+G( s )H( s ) i n t he
RHP i s z e r o \n\n Hence t h e system i s s t a b l e ” )

107
Figure 15.5: Output of S 15.05

Example 15.07 15.07.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ , 1 2 / ( s ∗( s +1) ∗( s +2) ) )
3 nyquist ( s y s )
4 show margins ( sys , ’ n y q u i s t ’ )
5 gm=g margin ( s y s )
6 i f (gm<=0)
7 p r i n t f ( ” system i s u n s t a b l e ” )
8 else
9 p r i n t f ( ” system i s s t a b l e ” ) ; end ;

108
Figure 15.6: Output of S 15.06

Example 15.08 15.08.sci

1 s=%s ;
2 s y s=s y s l i n ( ’ c ’ , ( 3 0 ) / ( ( s ˆ2+2∗ s +2) ∗( s +3) ) )
3 nyquist ( s y s )
4 gm=g margin ( s y s )
5 show margins ( sys , ’ n y q u i s t ’ )
6 p r i n t f ( ” S i n c e P=0(no o f p o l e s i n RHP)=P o l e s o f G( s )H( s )
\n Here t he number o f z e r o s o f 1+G( s )H( s ) i n th e
RHP i s z e r o \n Hence t h e system i s s t a b l e ” )
7 i f (gm<=0)
8 p r i n t f ( ” system i s u n s t a b l e ” )

109
Figure 15.7: Output of S 15.07

9 else
10 p r i n t f ( ” system i s s t a b l e ” )
11 end

110
Figure 15.8: Output of S 15.08

111
Chapter 17

State Variable Approach

Install Symbolic Toolbox.Refer the spoken tutorial on the link (www.spoken-


tutorial.org) for the installation of Symbolic Toolbox.

17.1 Scilab Code


Example 17.03 17.03.sci

1 s=%s ;
2 // C r e a t i n g cont −time transfer function
3 TFcont=s y s l i n ( ’ c ’ , 3 / ( s ˆ4+(2∗ s ˆ 3) +(3∗ s ) +2) )
4 SScont=t f 2 s s ( TFcont )
5 / / CCF form
6 [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScon ( 3 ) )

Example 17.04 17.04.sci

1 s=%s ;
2 TFcont=s y s l i n ( ’ c ’ , [ ( 7 + 2∗ s + 3∗( s ˆ 2) ) / (5 + 12∗ s + 5∗( s
ˆ 2) + s ˆ3 ) ] )
3 SScont=t f 2 s s ( TFcont )
4 [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) )

Example 17.06 17.06.sci

112
1 s=%s ;
2 // C r e a t i n g cont −time transfer function
3 TFcont=s y s l i n ( ’ c ’ , [ ( 5 ∗ ( s +1) ∗( s +2) ) / ( ( s +4) ∗( s +5) ) ] )
4 SScont=t f 2 s s ( TFcont )
5 / / CCF form
6 [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) )

Example 17.07 17.07.sci

1 s=%s ;
2 // C r e a t i n g cont −time transfer function
3 TFcont=s y s l i n ( ’ c ’ , ( s +1) / ( ( s +2) ∗( s +5) ∗( s +3) ) )
4 SScont=t f 2 s s ( TFcont )
5 / / CCF form
6 [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) )

Example 17.08 17.08.sci

1 s=%s ;
2 // C r e a t i n g cont −time transfer function
3 TFcont=s y s l i n ( ’ c ’ , ( 6 ) / ( ( s +2) ˆ2∗( s +1) ) )
4 SScont=t f 2 s s ( TFcont )
5 / / CCF form
6 [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) )

Example 17.09 17.09.sci

1 A=[0 1; −6 −5]
2 [ Row Col ]= s i z e (A) / / S i z e o f a m a t r i x
3 l=poly ( 0 , ’ l ’ ) ;
4 m=l ∗eye (Row, Col )−A / / l I −A
5 n=det (m) / / T o F i n d T h e D e t e r m i n a n t of l i −A
6 roots ( n ) / / T o F i n d T h e V a l u e O f l

Example 17.10 17.10.sci

1 A=[−2 1 ; 0 −3]

113
2 B= [ 0 ; 1 ]
3 C=[1 1 ]
4 s=poly ( 0 , ’ s ’ ) ;
5 [ Row Col ]= s i z e (A) // S i z e of a matrix
6 m=s ∗eye (Row, Col )−A / / s I −A
7 n=det (m) / / To F i n d T h e D e t e r m i n a n t of s i −A
8 p=inv (m) / / To F i n d T h e I n v e r s e O f s I −A
9 y=C∗p∗B ; / / T o F i n d C ∗ ( s I −A ) ˆ − 1 ∗ B
10 disp ( y , ” T r a n s f e r Function=” )

Example 17.11 17.11.sci

1 A=[0 1; −6 −5]
2 x=[1;0];
3 disp ( x , ”x ( t ) = ’)
4 s=p o l y ( 0 , ’ s ’ ) ;
5 [ Row Col ]= s i z e (A) // S i z e o f a matrix
6 m=s ∗ eye (Row, Col )−A // s I −A
7 n=d e t (m) //To Find The Determinant o f s i −A
8 p=i n v (m) ; // To Find The I n v e r s e Of s I −A
9 syms t s ;
10 d i s p ( p , ” p hi ( s )=” ) // R e s o l v e n t Matrix
11 f o r i =1:Row
12 f o r j =1: Col
13 // Taking I n v e r s e L a p l a c e o f each element o f Matrix p h i (
s)
14 q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ;
15 end ;
16 end ;
17 d i s p ( q , ” p h i ( t )=” ) // S t a t e T r a n s i t i o n Matrix
18 r=i n v ( q ) ;
19 r=s i m p l e ( r ) ; //To Find ph i (− t )
20 d i s p ( r , ” p h i (− t )=” )
21 y=q∗x ; //x ( t )=p h i ( t ) ∗x ( 0 )
22 d i s p ( y , ” S o l u t i o n To The g i v e n eq .=” )

Example 17.12 17.12.sci

114
1 A=[0 1; −6 −5]
2 B= [ 0 ; 1 ]
3 x=[1;0]
4 disp ( x , ”x ( t ) = ’)
5 s=p o l y ( 0 , ’ s ’ ) ;
6 [ Row Col ]= s i z e (A) // S i z e o f a matrix A
7 m=s ∗ eye (Row, Col )−A // s I −A
8 n=d e t (m) //To Find The Determinant o f s i −A
9 p=i n v (m) ; // To Find The I n v e r s e Of s I −A
10 syms t s m;
11 d i s p ( p , ” p hi ( s )=” ) // R e s o l v e n t Matrix
12 f o r i =1:Row
13 f o r j =1: Col
14 // I n v e r s e L a p l a c e o f each element o f Matrix ( p hi ( s ) )
15 q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ;
16 end ;
17 end ;
18 d i s p ( q , ” p h i ( t )=” ) // S t a t e T r a n s i t i o n Matrix
19 t =(t−m) ;
20 q=e v a l ( q ) //At t=t−m , e v a l u a t i n g q i . e p hi ( t−m)
21 // I n t e g r a t e q w. r . t m( I n d e f i n i t e I n t e g r a t i o n )
22 r=i n t e g ( q∗B,m)
23 m=0 // Upper l i m i t i s t
24 g=e v a l ( r ) // P u t t i n g t h e v a l u e o f upper l i m i t i n q
25 m=t // Lower Limit i s 0
26 h=e v a l ( r ) // P u t t i n g t he v a l u e o f l o w e r l i m i t i n q
27 y=(h−g ) ;
28 d i s p ( y , ”y=” )
29 p r i n t f ( ”x ( t )= p hi ( t ) ∗x ( 0 ) + i n t e g ( ph i ( t−m) ∗B) w. r . t m
from 0 t 0 t \n” )
30 // x ( t )=ph i ( t ) ∗x ( 0 )+i n t e g ( ph i ( t−m) ∗B) w. r . t m from 0 t 0
t
31 y1=(q∗x )+y ;
32 d i s p ( y1 , ”x ( t )=” )

Example 17.13 17.13.sci

1 A=[3 0 ; 2 4 ]

115
2 B= [ 0 ; 1 ]
3 Cc=cont mat (A, B) ;
4 disp ( Cc , ” C o n t r o l a b i l i t y Matrix=” )
5 / / To Check Whether the m a t r i x ( Cc ) is singular i . e
determint of Cc =0
6 i f determ ( Cc ) ==0;
7 p r i n t f ( ” S i n c e t h e matrix i s S i n g u l a r , t he system i s
not c o n t r o l l a b l e \n” ) ;
8 else ;
9 p r i n t f ( ”The system i s c o n t r o l l a b l e \n” )
10 end ;

Example 17.14 17.14.sci

1 A=[−2 1 ; 0 −3]
2 B= [ 4 ; 1 ]
3 C=[1 0 ]
4 [O]=obsv mat (A,C) ;
5 disp (O, ” O b s e r v a b i l i t y Matrix=” )
6 / / To Check Whether the m a t r i x ( Cc ) i s singular i . e
determint of Cc =0
7 i f determ (O) ==0;
8 p r i n t f ( ” S i n c e t h e matrix i s S i n g u l a r , t he system i s not
O b s e rv a b l e \n” ) ;
9 else ;
10 p r i n t f ( ”The system i s O bs e r v a b l e \n” )
11 end ;

Example 17.16 17.16.sci

1 s=%s ;
2 // C r e a t i n g cont −time transfer function
3 TFcont=s y s l i n ( ’ c ’ , ( ( 5 ∗ s ˆ 2 ) +(2∗ s ) +6) / ( s ˆ3+(7∗ s ˆ 2 ) +(11∗ s )
+8) )
4 SScont=t f 2 s s ( TFcont )
5 / / CCF form
6 [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) )

116
Example 17.17 17.17.sci

1 s=%s ;
2 // C r e a t i n g cont −time transfer function
3 TFcont=s y s l i n ( ’ c ’ , ( 8 ) / ( s ∗( s +2) ∗( s +3) ) )
4 SScont=t f 2 s s ( TFcont )
5 / / CCF form
6 [ Ac , Bc , U, in d ]=canon ( SScont ( 2 ) , SScont ( 3 ) )

Example 17.18 17.18.sci

1 A=[0 1; −3 −4]
2 x=[1;0];
3 disp ( x , ”x ( t ) = ’)
4 s=p o l y ( 0 , ’ s ’ ) ;
5 [ Row Col ]= s i z e (A) // S i z e o f a matrix
6 m=s ∗ eye (Row, Col )−A // s I −A
7 n=d e t (m) //To Find The Determinant o f s i −A
8 p=i n v (m) ; / / To Find The I n v e r s e Of s I −A
9 syms t s ;
10 d i s p ( p , ” p hi ( s )=” ) // R e s o l v e n t Matrix
11 f o r i =1:Row
12 f o r j =1: Col
13 // Taking I n v e r s e L a p l a c e o f each element o f Matrix p h i (
s)
14 q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ;
15 end ;
16 end ;
17 d i s p ( q , ” p h i ( t )=” ) // S t a t e T r a n s i t i o n Matrix
18 r=i n v ( q ) ;
19 r=s i m p l e ( r ) ; //To Find p hi (− t )
20 d i s p ( r , ” p h i (− t )=” )

Example 17.19 17.19.sci

1 A=[0 1; −3 −4]
2 B= [ 0 ; 1 ]
3 C=[1 0 ]

117
4 x=[0;0]
5 disp ( x , ”x ( t ) = ’)
6 s=p o l y ( 0 , ’ s ’ ) ;
7 [ Row Col ]= s i z e (A) // S i z e o f a matrix A
8 m=s ∗ eye (Row, Col )−A // s I −A
9 n=d e t (m) //To Find The Determinant o f s i −A
10 p=i n v (m) ; // To Find The I n v e r s e Of s I −A
11 syms t s m;
12 d i s p ( p , ” p hi ( s )=” ) // R e s o l v e n t Matrix
13 f o r i =1:Row
14 f o r j =1: Col
15 // Taking I n v e r s e L a p l a c e o f each element o f Matrix ( ph i (
s))
16 q ( i , j )=i l a p l a c e ( p ( i , j ) , s , t ) ;
17 end ;
18 end ;
19 d i s p ( q , ” p h i ( t )=” ) // S t a t e T r a n s i t i o n Matrix
20 t =(t−m)
21 q=e v a l ( q ) //At t=t−m , e v a l u a t i n g q i . e p hi ( t−m)
22 r=i n t e g ( q∗B,m) // I n t e g r a t e q w. r . t m ( I n d e f i n i t e
Integration )
23 m=0 // Upper l i m i t i s t
24 g=e v a l ( r ) // P u t t i n g t h e v a l u e o f upper l i m i t i n q
25 m=t // Lower Limit i s 0
26 h=e v a l ( r ) // P u t t i n g t he v a l u e o f l o w e r l i m i t i n q
27 y=(h−g ) ;
28 p r i n t f ( ”x ( t )= p hi ( t ) ∗x ( 0 ) + i n t e g ( ph i ( t−m) ∗B) w. r . t m
from 0 t 0 t \n” )
29 // x ( t )=ph i ( t ) ∗x ( 0 ) + i n t e g ( ph i ( t−m) ∗B) w. r . t m from 0
t0 t
30 y1=(q∗x )+y ;
31 d i s p ( y1 , ”x ( t )=” )
32 y2=C∗y1 ;
33 d i s p ( y2 , ” Output Response=” )

Example 17.20 17.20.sci

1 A=[0 1; −2 0 ]

118
2 B= [ 0 ; 3 ]
3 Cc=cont mat (A, B) ;
4 disp ( Cc , ” C o n t r o l a b i l i t y Matrix=” )
5 / / To Check Whether the m a t r i x ( Cc ) is singular i . e
determint of Cc =0
6 i f determ ( Cc ) ==0;
7 p r i n t f ( ” S i n c e t h e matrix i s S i n g u l a r , t he system i s not
c o n t r o l l a b l e \n” ) ;
8 else ;
9 p r i n t f ( ”The system i s c o n t r o l l a b l e \n” )
10 end ;

Example 17.21 17.21.sci

1 A=[−3 0 ; 0 −2]
2 B= [ 4 ; 1 ]
3 C=[2 0 ]
4 [O]=obsv mat (A,C) ;
5 disp (O, ” O b s e r v a b i l i t y Matrix=” )
6 / / To Check Whether the m a t r i x ( Cc ) is singular i . e
determint of Cc =0
7 i f determ (O) ==0;
8 p r i n t f ( ” S i n c e t h e matrix i s S i n g u l a r , t he system i s not
O b s e rv a b l e \n” ) ;
9 else ;
10 p r i n t f ( ”The system i s O bs e r v a b l e \n” )
11 end ;

Example 17.22 17.22.sci

1 i eee ( 2 )
2 A=[−3 0 0 ; 0 −1 1 ; 0 0 −1]
3 B= [ 0 ; 1 ; 0 ]
4 s=poly ( 0 , ’ s ’ ) ;
5 [ Row Col ]= s i z e (A) // S i z e of a matrix
6 m=s ∗eye (Row, Col )−A / / s I −A
7 n=det (m) / / To F i n d The Determinant of s i −A
8 p=inv (m) ; / / To F i n d The Inverse Of s I −A

119
9 syms t s ;
10 disp ( p , ” ph i ( s )=” ) // R e s o l v e n t Matrix

Example 17.23 17.23.sci

1 A=[−2 0 ; 1 −1]
2 B= [ 0 ; 1 ]
3 x=[0;0]
4 disp ( x , ”x ( t ) = ’)
5 s=p o l y ( 0 , ’ s ’ ) ;
6 [ Row Col ]= s i z e (A) // S i z e o f a matrix A
7 m=s ∗ eye (Row, Col )−A // s I −A
8 n=d e t (m) //To Find The Determinant o f s i −A
9 p=i n v (m) ; // To Find The I n v e r s e Of s I −A
10 syms t s m;
11 d i s p ( p , ” p hi ( s )=” ) // R e s o l v e n t Matrix
12 t =(t−m)
13 q=e v a l ( q ) //At t=t−m , e v a l u a t i n g q i . e p hi ( t−m)
14 // I n t e g r a t e q w. r . t m ( I n d e f i n i t e I n t e g r a t i o n )
15 r=i n t e g ( q∗B,m)
16 m=0 // Upper l i m i t i s t
17 g=e v a l ( r ) // P u t t i n g t h e v a l u e o f upper l i m i t i n q
18 m=t // Lower Limit i s 0
19 h=e v a l ( r ) // P u t t i n g t he v a l u e o f l o w e r l i m i t i n q
20 y=(h−g ) ;
21 d i s p ( y , ”y=” )
22 p r i n t f ( ”x ( t )= p hi ( t ) ∗x ( 0 ) + i n t e g ( ph i ( t−m) ∗B) w. r . t m
from 0 t 0 t \n” )
23 // x ( t )=ph i ( t ) ∗x ( 0 )+i n t e g ( ph i ( t−m) ∗B)w. r . t m from 0 t 0 t
24 y1=(q∗x )+y ;
25 d i s p ( y1 , ”x ( t )=” )
26 // CONTROLABILITY OF THE SYSTEM
27 Cc=cont mat (A, B) ;
28 d i s p ( Cc , ” C o n t r o l a b i l i t y Matrix=” )
29 //To Check Whether t h e matrix ( Cc ) i s s i n g u l a r i . e
d e t e r m i n t o f Cc=0
30 i f determ ( Cc ) ==0;

120
31 p r i n t f ( ” S i n c e t h e matrix i s S i n g u l a r , th e system i s not
c o n t r o l l a b l e \n” ) ;
32 else ;
33 p r i n t f ( ”The system i s c o n t r o l l a b l e \n” )
34 end ;

121
Chapter 18

Digital Control Systems

For the execution of the programm keep the main programm and the Func-
tion in the same folder.

18.1 Scilab Code


Example F3 ztransfer.sce

1 function [ Z t r a n s f e r ]= z t r a n s f e r ( s e q u e n c e )
2 z = poly ( 0 , ’ z ’ , ’ r ’ )
3 Z t r a n s f e r=s e q u e n c e ∗(1/ z ) ˆ [ 0 : ( length ( s e q u e n c e ) −1) ] ’
4 endfunction

Example 18.01 18.01.01.sci

1 syms n z ;
2 x=( −0.5) ˆn
3 y = ( 4 ∗ ( ( 0 . 2 ) ˆn ) )
4 f 1=symsum ( x ∗( zˆ(−n ) ) , n , 0 , %inf )
5 f 2=symsum ( y ∗( zˆ(−n ) ) , n , 0 , %inf )
6 y=( f 1+f 2 ) ;
7 disp ( y , ” ans=” )

Example 18.08 18.08.01.sci

122
1 exec z t r a n s f e r . s c e ;
2 s e q u e n c e =[0 2 0 0 −3 0 0 8 ]
3 y=z t r a n s f e r ( s e q u e n c e ) ;
4 disp ( y , ” ans=” )

123

You might also like