0% found this document useful (0 votes)
2 views11 pages

04 - Contents

The document is a comprehensive guide to MATLAB, covering its introduction, history, installation, and environment. It includes detailed sections on vectors, matrices, programs, functions, and complex numbers, along with examples and exercises. The content is structured to facilitate learning and understanding of MATLAB's features and functionalities.

Uploaded by

edgardoehvcm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views11 pages

04 - Contents

The document is a comprehensive guide to MATLAB, covering its introduction, history, installation, and environment. It includes detailed sections on vectors, matrices, programs, functions, and complex numbers, along with examples and exercises. The content is structured to facilitate learning and understanding of MATLAB's features and functionalities.

Uploaded by

edgardoehvcm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Contents

1 Introduction to MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 What Is MATLAB? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 History, Purpose, and Importance . . . . . . . . . . . . . . . . . . . . . . 2
1.3.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Purpose and Importance . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Installation and Dependencies . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.1 Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Starting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 MATLAB Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.7 Features of MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.8 Variables in MATLAB: Categories and Conversion
Between Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.8.1 Categories of Data Types . . . . . . . . . . . . . . . . . . . . . 9
1.8.2 MATLAB Example 1.1: Different Data Types . . . . . . 9
1.8.3 Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.8.4 MATLAB Example 1.2: Conversion
of Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.9 Suppressing Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.10 Recording a MATLAB Session . . . . . . . . . . . . . . . . . . . . . . . 14
1.11 Printing Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.12 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Exercise 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2 Vectors and Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Creating Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3 Creating Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4 Manipulation of Vectors and Matrices . . . . . . . . . . . . . . . . . . 21

ix
x Contents

2.5 Dimensions of Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22


2.5.1 MATLAB Example 2.10: Dimension
of a Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.6 Operations on Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.6.1 Addition and Subtraction . . . . . . . . . . . . . . . . . . . . . 24
2.6.2 MATLAB Example 2.1: Addition
and Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.6.3 Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.6.4 MATLAB Example 2.2: Multiplication . . . . . . . . . . . 26
2.6.5 Transpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.6.6 MATLAB Example 2.3: Transpose . . . . . . . . . . . . . . 27
2.6.7 Determinant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.6.8 MATLAB Example 2.4: Determinant . . . . . . . . . . . . 28
2.6.9 Identity Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.6.10 MATLAB Example 2.5: Identity Matrix . . . . . . . . . . 28
2.6.11 Inverse Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.6.12 MATLAB Example 2.6: Inverse Matrix . . . . . . . . . . . 29
2.7 Simple Matrix Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.7.1 MATLAB Example 2.9: Matrix
Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.8 Creating Arrays of Zeros, Ones, and Random Numbers . . . . . . 31
2.8.1 MATLAB Example 2.7: Arrays
of Zeros and Ones . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.8.2 MATLAB Example 2.8: Random Numbers . . . . . . . . 33
2.9 Array Function for One-Dimensional Arrays . . . . . . . . . . . . . . 35
2.9.1 MATLAB Example 2.11: Creating Linearly
Spaced One-Dimensional Array . . . . . . . . . . . . . . . . . 35
2.9.2 MATLAB Example 2.12: Finding Maximum
and Minimum Value from an Array . . . . . . . . . . . . . . 37
2.10 Mean, Standard Deviation, Variance, and Mode . . . . . . . . . . . 37
2.10.1 MATLAB Example 2.13: Mean, Variance,
Standard Deviation, and Mode . . . . . . . . . . . . . . . . . 39
2.11 Dot Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.11.1 MATLAB Example 2.14: Instances
of the Dot Operator . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.12 Table Arrays, Cell Arrays, and Structure Arrays . . . . . . . . . . . 41
2.12.1 MATLAB Example 2.15: Creating Table . . . . . . . . . . 42
2.12.2 MATLAB Example 2.16: Cell Array . . . . . . . . . . . . . 43
2.12.3 MATLAB Example 2.17: Structured Array . . . . . . . . 44
2.13 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Exercise 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3 Programs and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.2 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.2.1 Live Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.2.2 Script vs. Live Script . . . . . . . . . . . . . . . . . . . . . . . . 51
Contents xi

3.3 Saving, Running, and Publishing a Script . . . . . . . . . . . . . . . . 52


3.3.1 Saving a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.3.2 Running a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.3.3 Publishing a Script . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.4 Conditional Statements and Loops . . . . . . . . . . . . . . . . . . . . . 56
3.4.1 “If” Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.4.2 MATLAB Example 3.1: “If” Statement . . . . . . . . . . . 58
3.4.3 Switch Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.4.4 MATLAB Example 3.2: Switch Statement . . . . . . . . . 60
3.4.5 For Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.4.6 MATLAB Example 3.3: “For” Loop . . . . . . . . . . . . . 62
3.5 User-Defined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.6 Creating User-Defined Functions . . . . . . . . . . . . . . . . . . . . . . 63
3.6.1 MATLAB Example 3.4: User-Defined Function . . . . . 64
3.6.2 MATLAB Example 3.5: User-Defined
Function–Anonymous Function . . . . . . . . . . . . . . . . . 65
3.6.3 Examples of User-Defined Function . . . . . . . . . . . . . . 65
3.7 Solve Quadratic Equations Using Functions . . . . . . . . . . . . . . 68
3.7.1 MATLAB Example 3.6: User-Defined Function
for Solving Quadratic Equation . . . . . . . . . . . . . . . . . 69
3.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Exercise 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.2 Origin of Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.3 Rectangular Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.3.1 MATLAB Example 4.1: Rectangular Form . . . . . . . . 73
4.4 Polar Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.4.1 MATLAB Example 4.2: Polar Form . . . . . . . . . . . . . 74
4.5 Euler’s Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.5.1 MATLAB Example 4.3: Euler’s Formula . . . . . . . . . . 76
4.5.2 MATLAB Example 4.4: Euler’s Series
for Solving Initial Value Problem . . . . . . . . . . . . . . . 77
4.6 Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.6.1 MATLAB Example 4.5: Fourier Series . . . . . . . . . . . 80
4.6.2 MATLAB Example 4.6: DFT and Inverse DFT . . . . . 82
4.7 Taylor Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.7.1 MATLAB Example 4.7: Taylor Series . . . . . . . . . . . . 84
4.8 Equilibrium Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.8.1 MATLAB Example 4.8: Equilibrium Points . . . . . . . . 86
4.9 Energy Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.9.1 MATLAB Example 4.9: Energy Calculation . . . . . . . 87
xii Contents

4.10 Impedance Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89


4.10.1 MATLAB Example 4.10: Impedance
Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.11 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Exercise 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.2 Line Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.2.1 MATLAB Example 5.1: Line Plot . . . . . . . . . . . . . . . 98
5.2.2 MATLAB Example 5.2: Subplot . . . . . . . . . . . . . . . . 99
5.2.3 MATLAB Example 5.3: Double-Axis Plot . . . . . . . . . 100
5.3 Bar Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
5.3.1 MATLAB Example 5.4: Bar Plot . . . . . . . . . . . . . . . 102
5.3.2 MATLAB Example 5.5: Horizontal Bar Plot . . . . . . . 103
5.4 Area Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
5.4.1 MATLAB Example 5.6: Area Plot . . . . . . . . . . . . . . . 105
5.5 Surface Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
5.5.1 MATLAB Example 5.7: Surface Plot . . . . . . . . . . . . . 107
5.6 Pie Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
5.6.1 MATLAB Example 5.8: Pie Plot . . . . . . . . . . . . . . . . 109
5.7 Heat Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
5.7.1 MATLAB Example 5.9: Heat Map . . . . . . . . . . . . . . 110
5.8 Radar Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
5.8.1 MATLAB Example 5.10: Radar Plot . . . . . . . . . . . . . 112
5.9 3D Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
5.9.1 MATLAB Example 5.11: 3D Pie Plots . . . . . . . . . . . 115
5.10 Exporting High-Quality Figure . . . . . . . . . . . . . . . . . . . . . . . . 115
5.11 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Exercise 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
6 Solving Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
6.2 Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
6.2.1 MATLAB Example 6.1: Rank . . . . . . . . . . . . . . . . . . 124
6.2.2 MATLAB Example 6.2: Eigenvalue . . . . . . . . . . . . . 125
6.2.3 MATLAB Example 6.3: Eigenvector . . . . . . . . . . . . . 126
6.3 Quadratic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
6.3.1 MATLAB Example 6.4: Solving
Quadratic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . 127
6.3.2 MATLAB Example 6.5: “Solve” Function . . . . . . . . . 128
6.4 Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
6.4.1 Ordinary Differential Equations . . . . . . . . . . . . . . . . . 129
6.4.2 MATLAB Example 6.6: First-Order Differential
Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Contents xiii

6.4.3 MATLAB Example 6.7: Second-Order Differential


Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
6.4.4 MATLAB Example 6.8: Third-Order Differential
Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
6.4.5 Partial Differential Equations . . . . . . . . . . . . . . . . . . . 133
6.4.6 MATLAB Example 6.9: Partial Differential
Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
6.5 Integral Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
6.5.1 MATLAB Example 6.10: Single Variable Integral
Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
6.5.2 MATLAB Example 6.11: Multivariable Integral
Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
6.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Exercise 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
7 Numerical Methods in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.2 Gauss-Seidel Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.2.1 MATLAB Example 7.1: Gauss-Seidel Method . . . . . . 142
7.3 Newton-Raphson Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
7.3.1 MATLAB Example 7.2: Newton-Raphson Method . . . 144
7.4 Runge-Kutta Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
7.4.1 MATLAB Example 7.3: Runge-Kutta Method . . . . . . 146
7.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Exercise 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
8 Electrical Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
8.2 DC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
8.2.1 Ohm’s Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
8.2.2 Equivalent Resistance . . . . . . . . . . . . . . . . . . . . . . . . 152
8.2.3 Delta-Wye Conversion . . . . . . . . . . . . . . . . . . . . . . . 154
8.2.4 Kirchhoff’s Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.2.5 Voltage Divider and Current Divider Laws . . . . . . . . . 162
8.2.6 Thevenin’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . 164
8.2.7 Maximum Power Transfer Theorem . . . . . . . . . . . . . . 167
8.3 AC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.3.1 Some Terminologies . . . . . . . . . . . . . . . . . . . . . . . . . 170
8.3.2 Impedance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
8.3.3 Power Triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
8.3.4 Three-Phase AC Circuit Analysis . . . . . . . . . . . . . . . 176
8.4 Operational Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
8.4.1 Inverting Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . 198
8.4.2 Non-inverting Amplifier . . . . . . . . . . . . . . . . . . . . . . 199
8.4.3 Follower Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
xiv Contents

8.4.4 Differentiator Circuit . . . . . . . . . . . . . . . . . . . . . . . . 202


8.4.5 Integrator Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
8.5 Transistor Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
8.5.1 MATLAB Example 8.25: Transistor Circuit . . . . . . . . 208
8.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Exercise 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
9 Control System and MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
9.2 Frequency Response Overview . . . . . . . . . . . . . . . . . . . . . . . 215
9.2.1 Linear Time-Invariant System . . . . . . . . . . . . . . . . . . 216
9.2.2 Transfer Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
9.2.3 Laplace Transform . . . . . . . . . . . . . . . . . . . . . . . . . . 219
9.2.4 Inverse Laplace Transform . . . . . . . . . . . . . . . . . . . . 221
9.2.5 Partial Fraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
9.2.6 DC Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
9.2.7 Initial Value and Final Value Theorem . . . . . . . . . . . . 232
9.2.8 Poles/Zeros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
9.2.9 Laplace Transform in Electrical Circuit . . . . . . . . . . . 235
9.3 Time Response Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
9.3.1 First-Order System . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.3.2 Second-Order System . . . . . . . . . . . . . . . . . . . . . . . . 240
9.3.3 Impact of Damping Ratio . . . . . . . . . . . . . . . . . . . . . 242
9.3.4 Steady-State Error . . . . . . . . . . . . . . . . . . . . . . . . . . 255
9.4 A State-Space Representation for RLC Circuit . . . . . . . . . . . . 257
9.4.1 State-Space Model and Response . . . . . . . . . . . . . . . 258
9.4.2 State-Space Model to Transfer Function . . . . . . . . . . . 259
9.4.3 Transfer Function to State-Space Model . . . . . . . . . . . 261
9.5 Controllability and Observability of State-Space Model . . . . . . 262
9.5.1 Controllability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.5.2 Testing for Controllability . . . . . . . . . . . . . . . . . . . . . 264
9.5.3 Observability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
9.5.4 Testing for Observability . . . . . . . . . . . . . . . . . . . . . 264
9.6 Stability Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
9.6.1 Routh Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
9.6.2 Root Locus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
9.6.3 Bode Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
9.6.4 Nyquist Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
9.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Exercise 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
10 Optimization Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
10.2 One-Dimensional Optimization . . . . . . . . . . . . . . . . . . . . . . . 283
10.2.1 MATLAB Example 10.1: One-Dimensional
Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Contents xv

10.3 Multidimensional Optimization . . . . . . . . . . . . . . . . . . . . . . . 285


10.3.1 MATLAB Example 10.2: Multidimensional
Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
10.4 Linear Programming Optimization . . . . . . . . . . . . . . . . . . . . . 288
10.4.1 MATLAB Example 10.3: Linear Programming
Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
10.5 Quadratic Programming Optimization . . . . . . . . . . . . . . . . . . . 291
10.5.1 MATLAB Example 10.4: Quadratic Programming
Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
10.6 Nonlinear Programming Optimization . . . . . . . . . . . . . . . . . . . 293
10.7 Li-ion Battery Optimization Problem and Solutions . . . . . . . . . 293
10.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Exercise 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
11 App Designer and Graphical User Interface in MATLAB . . . . . . . . 299
11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
11.2 App Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
11.2.1 Basic Layout of App Designer . . . . . . . . . . . . . . . . . 299
11.2.2 Components of App Designer . . . . . . . . . . . . . . . . . . 302
11.2.3 Detecting and Correcting Errors . . . . . . . . . . . . . . . . 303
11.2.4 Designing and Programming a GUI
with App Designer . . . . . . . . . . . . . . . . . . . . . . . . . . 303
11.3 App Designer vs GUIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
11.4 GUIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
11.4.1 Exporting GUIDE App as MATLAB file . . . . . . . . . . 312
11.4.2 Migrate GUIDE App to App Designer . . . . . . . . . . . . 313
11.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Exercise 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
12 Introduction to Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
12.1 What Is Simulink? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
12.2 Starting Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
12.3 Basic Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
12.3.1 Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
12.3.2 Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
12.3.3 Other Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
12.4 Simulink Library Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
12.5 Physical System Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
12.6 Building a Model in Simulink . . . . . . . . . . . . . . . . . . . . . . . . 332
12.7 Simulate a Model in Simulink . . . . . . . . . . . . . . . . . . . . . . . . 334
12.7.1 “Run” Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
12.7.2 “Step Forward” and “Step Back” . . . . . . . . . . . . . . . . 337
12.7.3 Customizing the Style of the “Scope” Figure . . . . . . . 340
12.7.4 “Solver” Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
12.7.5 Data Import and Export . . . . . . . . . . . . . . . . . . . . . . 345
12.7.6 Math and Data Types . . . . . . . . . . . . . . . . . . . . . . . . 348
xvi Contents

12.7.7 Diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349


12.7.8 Other Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
12.8 User-Defined Block in Simulink . . . . . . . . . . . . . . . . . . . . . . . 351
12.9 Using MATLAB in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . 354
12.10 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Exercise 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
13 Commonly Used Simulink Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . 361
13.1 Sink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
13.1.1 Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
13.1.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
13.1.3 Floating Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
13.1.4 Add Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
13.1.5 XY Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
13.2 Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
13.2.1 Pulse Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
13.2.2 Ramp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
13.2.3 Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
13.2.4 Sine Wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
13.2.5 Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
13.3 Math Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
13.3.1 Abs and MinMax . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
13.3.2 Add, Subtract, and Sum of Elements . . . . . . . . . . . . . 382
13.3.3 Product and Divide . . . . . . . . . . . . . . . . . . . . . . . . . . 384
13.3.4 Sum and Sqrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
13.3.5 Complex to Magnitude-Angle and Complex
to Real-Imag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
13.3.6 Magnitude-Angle to Complex and Real-Imag
to Complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
13.3.7 Math Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
13.3.8 Trigonometric Function . . . . . . . . . . . . . . . . . . . . . . 394
13.3.9 Derivative and Integrator . . . . . . . . . . . . . . . . . . . . . 396
13.4 Port and Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
13.4.1 Subsystem, In1, and Out1 . . . . . . . . . . . . . . . . . . . . . 398
13.4.2 Mux and Demux . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
13.5 Logical Operator, Relational Operator, Programs,
and Lookup Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
13.5.1 Logical Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
13.5.2 Relational Operator . . . . . . . . . . . . . . . . . . . . . . . . . 404
13.5.3 If and Switch Case . . . . . . . . . . . . . . . . . . . . . . . . . . 404
13.5.4 Lookup Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
13.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Exercise 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Contents xvii

14 Control System in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417


14.1 Control System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
14.2 Open-Loop Control System . . . . . . . . . . . . . . . . . . . . . . . . . . 417
14.3 Closed-Loop Control System . . . . . . . . . . . . . . . . . . . . . . . . . 418
14.4 Open-Loop vs Closed-Loop Control System . . . . . . . . . . . . . . 418
14.5 Simulink Model Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
14.5.1 Open-Loop Control System . . . . . . . . . . . . . . . . . . . . 419
14.5.2 Closed-Loop Control System . . . . . . . . . . . . . . . . . . 422
14.6 Stability Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
14.6.1 Stable System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
14.6.2 Unstable System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
14.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Exercise 14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
15 Electrical Circuit Analysis in Simulink . . . . . . . . . . . . . . . . . . . . . . 443
15.1 Measure Voltage, Current, and Power of a Circuit . . . . . . . . . . 443
15.1.1 DC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 443
15.1.2 AC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 445
15.2 RLC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
15.2.1 AC RLC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . 449
15.2.2 DC RLC Circuit Analysis . . . . . . . . . . . . . . . . . . . . . 449
15.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Exercise 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
16 Application of Simulink in Power Systems . . . . . . . . . . . . . . . . . . . 455
16.1 Modeling Single-Phase Power Source in Simulink . . . . . . . . . . 455
16.2 Modeling Three-Phase AC Power Source in Simulink . . . . . . . 456
16.2.1 Three-Phase Wye-Connected AC Power Source . . . . . 458
16.2.2 Three-Phase Delta-Connected AC Power Source . . . . 461
16.3 Model of Three-Phase Series RLC Load with Three-Phase
AC Power Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
16.4 Model of Three-Phase Parallel RLC Load with Three-Phase
AC Power Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
16.5 Power Factor Calculation Simulink Model . . . . . . . . . . . . . . . 468
16.6 Modeling Different Power System Configurations . . . . . . . . . . 470
16.6.1 Balanced Y-Y Power System Configuration . . . . . . . . 471
16.6.2 Unbalanced Y-Y Power System Configuration . . . . . . 473
16.6.3 Balanced Δ Δ Power System Configuration . . . . . . 477
16.6.4 Unbalanced Δ Δ Power System Configuration . . . . 479
16.7 Electrical Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
16.7.1 DC Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
16.7.2 Asynchronous Machine . . . . . . . . . . . . . . . . . . . . . . 485
16.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Exercise 16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
xviii Contents

17 Application of Simulink in Power Electronics . . . . . . . . . . . . . . . . . 495


17.1 Diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
17.1.1 Diode Characteristics . . . . . . . . . . . . . . . . . . . . . . . . 495
17.1.2 Single-Phase Half-Wave Rectifier . . . . . . . . . . . . . . . 497
17.1.3 Single-Phase Full-Wave Rectifier . . . . . . . . . . . . . . . 499
17.1.4 Three-Phase Full-Wave Rectifier . . . . . . . . . . . . . . . . 504
17.2 Transistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
17.2.1 Bipolar Junction Transistors (BJTs) . . . . . . . . . . . . . . 508
17.2.2 MOSFET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
17.2.3 IGBT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
17.3 Operational Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
17.3.1 Inverting Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . 516
17.3.2 Non-inverting Amplifier . . . . . . . . . . . . . . . . . . . . . . 518
17.3.3 Differentiator Circuit . . . . . . . . . . . . . . . . . . . . . . . . 519
17.3.4 Integrator Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
17.4 Control Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
17.4.1 Pulse Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
17.4.2 Controlled Rectification with Thyristor . . . . . . . . . . . 528
17.4.3 Controlled Rectification with GTO . . . . . . . . . . . . . . 528
17.5 Facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
17.5.1 Reference Frame Transformation . . . . . . . . . . . . . . . . 534
17.5.2 Phase-Locked Loop (PLL) . . . . . . . . . . . . . . . . . . . . 536
17.5.3 Static Var Compensator . . . . . . . . . . . . . . . . . . . . . . 538
17.6 Modeling of Converters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
17.6.1 Model of DC-DC Converters . . . . . . . . . . . . . . . . . . 544
17.6.2 Model of DC-AC Converter . . . . . . . . . . . . . . . . . . . 553
17.6.3 Model of AC-DC Converter . . . . . . . . . . . . . . . . . . . 560
17.6.4 Model of AC-AC Converter . . . . . . . . . . . . . . . . . . . 563
17.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
Exercise 17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
18 Application of Simulink in Renewable Energy Technology . . . . . . . 569
18.1 Solar Photovoltaics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
18.1.1 Mathematical Model of PV Cell . . . . . . . . . . . . . . . . 569
18.1.2 PV Panel Design from Solar Cell . . . . . . . . . . . . . . . . 571
18.1.3 PV Panel Design with PV Array . . . . . . . . . . . . . . . . 577
18.1.4 Case Study: Grid-Connected PV Array . . . . . . . . . . . 581
18.2 Wind Turbine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
18.2.1 Model Wind Turbine-Based Generator in Simulink . . . 594
18.2.2 Case Study: Grid-Connected Wind
Turbine Generator . . . . . . . . . . . . . . . . . . . . . . . . . . 600
18.3 Hydraulic Turbine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
18.3.1 Case Study: Hydro Turbine and Power Generator
Model in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . 611
Contents xix

18.4 Battery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619


18.4.1 Battery Cell Implementation in Simulink . . . . . . . . . . 620
18.4.2 Battery Modeling of Different Types
in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
18.4.3 Case Study: Battery Pack Design Using
Battery Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
18.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
Exercise 18 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631

Answer Keys to the End-of-Chapter Exercises . . . . . . . . . . . . . . . . . . . . 633

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy