Power Electronics Matlab
Power Electronics Matlab
Power Electronics Matlab
L. Ashok Kumar
A. Kalaiarasi
Y. Uma Maheswari
University Printing House, Cambridge cb2 8bs, United Kingdom
One Liberty Plaza, 20th Floor, New York, ny 10006, USA
477 Williamstown Road, Port Melbourne, vic 3207, Australia
314 to 321, 3rd Floor, Plot No.3, Splendor Forum, Jasola District Centre, New Delhi 110025, India
79 Anson Road, #06–04/06, Singapore 079906
www.cambridge.org
Information on this title: www.cambridge.org/9781316642313
© Cambridge University Press 2018
This publication is in copyright. Subject to statutory exception
and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.
First published 2018
Printed in India
A catalogue record for this publication is available from the British Library
ISBN 978-1-316-64231-3 Paperback
Additional resources for this publication at www.cambridge.org/9781316642313
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. The MathWorks Publisher Logo
identifies books that contain “MATLAB®” and “Simulink®” content. Used with permission.
The MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of
“MATLAB®” and/or “Simulink®” software or related products does not constitute endorsement or sponsorship by
The MathWorks of a particular use of the “MATLAB®” and/or “Simulink®” software or related products.
To our families
Contents
Figures xv
Tables xxv
Acknowledgements xxvii
Preface xxix
1. Introduction to MATLAB
1.1 Introduction and Outlook 1
1.2 How to Start with MATLAB? 2
1.2.1 Installing and activation 3
1.3 MATLAB: A Calculator 4
1.3.1 Basic arithmetic operations 5
1.3.2 Assigning values to variables 6
1.4 Basic Features of MATLAB 10
1.4.1 Investigation of a MATLAB function 10
1.4.2 Mathematical functions 10
1.4.3 Vector and matrix operations 12
1.4.4 Arrays 21
1.4.5 Basic plotting 24
1.5 Programming with MATLAB 26
1.5.1 Creating M-files 26
1.5.2 M-file functions 27
1.5.3 Control structures and operators 28
1.5.4 Debugging M-files 31
1.5.5 Creating plots 32
viii Contents
The authors are thankful to the Almighty for giving them the strength to persevere and for
their achievements.
The authors owe gratitude to Shri L Gopalakrishnan, Managing Trustee, PSG Institutions,
Dr K. V. Kuppusamy, Managing Trustee, RVS Institutions, Dr R. Rudramoorthy, Principal,
PSG College of Technology, Coimbatore, India and Dr V. Gunaraj, Principal, RVS College
of Engineering and Technology, Coimbatore for their whole-hearted cooperation and
encouragement for this successful endeavor.
Dr L. Ashok Kumar takes this opportunity to acknowledge many people who helped
him in completing this book. This book would not have come to its completion without the
help of my students, my department staff and my institute, and especially my project staff. I
am thankful to all my students doing their projects and research work with me. The writing
of this book would have been impossible without the support of my family members;
parents and sisters. Most importantly, I am very grateful to my wife, Y. Uma Maheswari,
for her constant support during the writing: without her nothing would have been possible.
I would like to express my special gratitude to my daughter A. K. Sangamithra for her
smiling face and support, which helped a lot in completing this work.
Professor A. Kalaiarasi would like to acknowledge her deep sense of gratitude to
her family, specially her daughter V. K. Meha for the patience and endless support in
completing this book. Most importantly, I take this opportunity to thank my supervisor
Dr L. Ashok Kumar for giving me a chance to work on this writing alongside him. This
acknowledgment would not be complete without expressing my gratitude to my friends
and students for their constant support.
We thank the personnel at Cambridge University Press, who produced the book. In
addition, special thanks to Rachna Sehgal, the Associate Commissioning Editor for this
book.
Preface
Unlike electronic systems that transmit and process signals and data, power electronics
involves the processing of substantial amounts of electrical energy. The power range begins
with tens of watts to a few hundred watts in the common AC/DC converter (rectifier) used
in consumer electronic devices such as battery chargers, personal computers or television
sets. In the industry, a common application such as the Variable Speed Drive (VSD), which
is used to control an induction motor, has a power range that starts from a few hundred
watts and can go upto tens of megawatts.
Beginnning with high-vacuum and gas-filled diode thermionic rectifiers, and triggered
devices such as the thyratron and ignitron, the field has evolved to a stage where it can be
said that today power electronics is the application of solid-state electronics to the control
and conversion of electric power. Steady improvements in the voltage and current handling
capacity of solid state devices have made this possible.
During the past few decades the technical aspect of power electronics and drives has
gone through significant scientific progression. Many inventions in strategy, apparatus,
circuit, control and systems have made power electronics a formidable technology during
this period. MATLAB helps learners understand the field because it integrates computation,
visualization, and programming in an easy-to-use environment where problems and
solutions are expressed in familiar mathematical notation. This book introduces this
promising technology with MATLAB/SIMULÏNK in Power Electronic Circuits. It
addresses the progress of early semiconductor devices and then moves on to introduce
recently developed high-performance power semiconductor switching devices and their
applications using MATLAB/SIMULÏNK. It also gives a condensed review of the current
power electronic circuits and their outcomes.
The ultimate purpose of this book is to help engineering students engage in energy
conversion on the up-to-date electronic applications. It covers almost all features and
xxx Preface
Learning Objectives
To introduce the fundamental concepts of MATLAB programming
The installation and activation process can be accomplished in any of the following two
ways:
• Using an Internet connection
• Without using an Internet connection
Introduction to MATLAB 3
Before installing, proceed with the steps shown in Tables 1.1 and 1.2.
Table 1.1 Installing and activating using an Table 1.2 Installing and activating without using
Internet connection an Internet connection
Step 9 Select the installation options Step 9 Confirm the choice of selection
Once the installation is completed we can start the program using the following steps:
• GOTO start menu
• Double click MATLAB icon
The desktop then appears with the default layout as shown in Figure 1.1, which is the
startup page of MATLAB.
From Figure 1.1, we can see some of the default panels that include: Start button,
command window, current folder, workspace and command history.
Start button We can single click the button for better access of tools and functions.
4 Power Electronics with MATLAB
Command window In the command window, we can enter commands at the command
line, which is indicated by fx>> (This is the command prompt).
Current folder We can access all the MATLAB files from the directory.
Workspace We can explore all the data sets that are imported from the files.
Command history We can view or analyze the commands given in the command
window.
As we start up with MATLAB, the user can type some of the commands, such as helpwin,
helpdesk and demo for better understanding of MATLAB functions and operations.
Since MATLAB is an inferred type language, the variables can be assigned using the
operator ‘=’ without the declaration of their type. Some examples of computation involving
variables and constants are shown here:
Introduction to MATLAB 5
Example 1
>> x = 100
MATLAB responds with
x =
100
Example 2
>> x = “hello”
Example 3
>> x = pi
MATLAB responds with
x =
3.1416
In Figure 1.2, the mathematical computations of arithmetic operations are shown in the
MATLAB window. Thus, it can be clearly seen that the MATLAB tool can be used purely
as a calculator that performs mathematical and scientific operations.
Here the value can be a function call, operator, variable or a numerical value. Consider the
following examples of assigning values to the variables.
Introduction to MATLAB 7
Example 9
>> a = 2
a = 2
Example 10
>> a = 6
a = 6
>> b = a^2
b = 36
Example 11
>> b = pi/6
b = 0.523626
Example 12
>> c = b + a^0.25
c = 1.7128
In Example 12, it is noted that the variable which is named c exists only as a numerical
value.
8 Power Electronics with MATLAB
Example 13
>>who
Your variables are
a ans b c
The ‘who’ command represents the list of active variables that are currently available.
Example 14
>> clc
The ‘clc’ command clears the screen. It refreshes or empties the command window for a
new set of operations.
Figure 1.3 shows how to assign values to variables in the MATLAB window.
Some of the other tasks available in MATLAB computing are overwriting of variables,
controlling the hierarchy, controlling the precision of floating points, multiple statements
and display of error message.
Example 15
Overwriting of variables
>> a = 7;
Introduction to MATLAB 9
>> a = a + 4
a =
11
The purpose of the semicolon (;) is to suppress the result after execution.
Example 16
Controlling the hierarchy
>>a = (1 + 2) * 3
a =
9
>> a = 1 + 2 * 3
a =
7
Here similar expressions produce different results. To avoid erroneous results, MATLAB
considers hierarchy of mathematical operations to perform calculations.
Example 17
Controlling the precision of the floating number
The length of the floating number of the assigned variable can be increased or decreased
using the syntax
“format short”
“format long”
>> 1/5987666555
ans =
1.670099680425508e−10
>> format short
>> x = 1/56565656565
x =
1.7679e−11
>> format long
>> x = 1/56565656565
x =
1.767857142877663e−11
10 Power Electronics with MATLAB
Example 18
Multiple statements
>> a = 4;
>> b = cos(a) * sin(a)
b =
0.494679123311691
The execution of multiple statements includes the execution of all linear expressions
separated by commas (,) or semicolons (;).
Example 19
Display of error messages
>> x = 12; y = 32;
z = x + w
Undefined function or variable ‘w’.
When an undefined variable is being executed, the MATLAB responds with an error stating
‘undefined function or variable’.
To terminate the session, we use the command called ‘quit’ in the command window to
exit the application.
Like BASIC language, the large set of various arithmetic operations can be assigned to the
variables that are defined. The basic syntax of mathematical functions are listed here:
Introduction to MATLAB 11
Trigonometric Functions
acos (x) Inverse cosine; arcos x = cos − 1 (x)
asin (x) Inverse sine; arcsin x = sin − 1 (x)
atan (x) Inverse tangent; arctan x = tan − 1 (x)
cos (x) Cosine; cos(x)
sin (x) Sine; sin(x)
tan (x) Tangent; tan(x)
Some of the other types of trigonometric functions include acot (x), acsc (x), asec (x),
atan2(y, x), cot (x), csc (x), and sec (x).
Hyperbolic Functions
acosh (x) Inverse hyperbolic cosine; cosh − 1 (x)
acoth (x) Inverse hyperbolic cotangent; coth − 1 (x)
cosh (x) Hyperbolic cosine; cosh(x)
coth (x) Hyperbolic cotangent; cosh(x)/sinh(x)
sech (x) Hyperbolic secant; 1/cosh(x)
sinh (x) Hyperbolic sine; sinh(x)
Other types of hyperbolic functions include acoth (x), acsch (x), asech (x), atanh (x), asinh
(x), csch (x) and tanh (x).
Complex Functions
abs (x) Absolute value; |x|
angle (x) Complex number angle x
conj (x) Complex conjugate of x
imag (x) Imaginary part of a complex number x
real (x) Real part of a complex number x
12 Power Electronics with MATLAB
Statistical Functions
Numeric Functions
ceil Rounds to the nearest integer towards •
fix Rounds values to the nearest integer towards zero
floor Rounds to the nearest integer towards •
round Rounds to the nearest integer
sign Signup function
String Functions
findstr Occurrence of a string
strcmp String comparison
char String array character
Example 20
Solve for the expression g = sin(x) + sin(y)(log x) + e1 with values of x = 3, y = 7 and z = 6.
>> x = 3; y = 7; z = 6;
>> g = sin(x) + sin(y) * log(x) + exp(1)
g =
3.581175387361639
MATLAB is an easy to understand tool that helps in controlling matrices and vector
ideas. The essential functions of MATLAB rotate around the use of vectors and a vector is
Introduction to MATLAB 13
Example 21
A>> v = [1 2 3 4 5 6 7 8 9] click ENTER
v =
1 2 3 4 5 6 7 8 9
A column vector can also be characterized with an exhibit of m × 1 measurements. Like the
line vector, the estimates can be encased inside a square section divided by spaces or with
commas. Column vectors can even be made by utilizing semicolons (;) inside the square
sections to divide the values. To make a section vector, simply take the transpose of the row
vector utilizing the image ('). Following are illustrations for a segment vector.
Example 22
>> v = [−34 56 −445 54 −2 −5]’ click ENTER
v =
−34
56
−445
54
−2
−5
Example 23
>> v = [1;7;9;67;9]
v =
1
7
9
67
9
14 Power Electronics with MATLAB
A vector can be of any length. Following is an exchange method for characterizing a vector
for a set of qualities.
Example 24
>> v = [1:9]
v =
1 2 3 4 5 6 7 8 9
Another method of manipulating vectors is by the addition of the vector with a scaling.
In this method, to get a component of a vector, we utilize the image colon (:). Assume,
for example that we need to characterize a vector with a beginning quality and the closure
esteem along with the addition esteem. The vector could be written as follows.
Example 25
>> v = [1:.20:7]
v =
Columns 1 through 3
1.000000000000000 1.200000000000000 1.400000000000000
Columns 4 through 6
1.600000000000000 1.800000000000000 2.000000000000000
Columns 7 through 9
2.200000000000000 2.400000000000000 2.600000000000000
Columns 10 through 12
2.800000000000000 3.000000000000000 3.200000000000000
Columns 13 through 15
3.400000000000000 3.600000000000000 3.800000000000000
Columns 16 through 18
4.000000000000000 4.199999999999999 4.400000000000000
Columns 19 through 21
4.600000000000000 4.800000000000000 5.000000000000000
Columns 22 through 24
5.200000000000000 5.400000000000000 5.600000000000000
Columns 25 through 27
5.800000000000000 6.000000000000000 6.200000000000000
Introduction to MATLAB 15
Columns 28 through 30
6.400000000000000 6.600000000000000 6.800000000000000
Column 31
7.000000000000000
From this illustration, it can be seen that a line of vectors beginning from 1 to 7 with
increment in the estimations of .20 is continuously registered. MATLAB executes the
entries that are needed faultlessly. Subsequently, a set of 31 sections are continuously
declared to characterize the given vector.
The following program accesses elements within the vector, just type
Example 26
>> v(4)
ans =
1.600000000000000
The result brings out the estimation of the vector created in Example 25, that is, the fourth
entrance of the vector has been printed. The other values are excluded. Therefore, the result
is continuously printed with the ans.
The following is a program that signifies the end value of the vector
Example 27
>> v(1, end)
ans =
7
The following program tracks the recent or the past result of a vector.
Example 28
>> ans’
ans =
1.600000000000000
A simple example for operating with vector is shown here.
Column vector:
Example 29
>> v = [1:5:8]; u = [3:6:4];
>> y = 2 * (u + v)
16 Power Electronics with MATLAB
y =
8 18
Row vector:
Example 30
>> v = [1:5:8]’; u = [3:6:4]’;
>> y = 5 * (u + v)
y =
20
45
Example 31
>> v(:) for column vector
>> v(1:end) for row vector
MATLAB, as a matter of course, stores all the outputs that have been executed, which is
convenient when substantial set of operations or reckonings are continuously done.
Example 32
>> x = [1 4 6; 2 4 5; 5 6 7]
x =
1 4 6
2 4 5
5 6 7
The transpose of this vector can be obtained by using the symbol (‘);
Introduction to MATLAB 17
Example 33
>> x = [1 4 6; 2 4 5; 5 6 7]’
x =
1 2 5
4 4 6
6 5 7
Henceforth, to manage matrix operations in MATLAB, the notations to be considered are
square section, commas and semicolon as said previously for vector operations.
To extract a particular element in a matrix, we can perform the following operation.
Example 34
>> x(1,3)
ans =
5
The element, being located in row 1 and column 3 of x in Example 33, is executed.
Consider a matrix
x =
1 2 5
4 4 6
6 5 7
The following example shows us how to replace, say, the second column and second row
value 4, by any other value, say 6.
Example 35
>>x(2,2) = 6
x =
18 Power Electronics with MATLAB
1 2 5
4 6 6
6 5 7
Zero and negative qualities are not acknowledged though the components can be obtained
as x(i, j) where i ≥ 1 and j
Example 36
Example 37
>> inv(x)
ans =
−0.230769230769231 −0.211538461538462 0.346153846153846
−0.153846153846154 0.442307692307692 −0.269230769230769
0.307692307692308 −0.134615384615385 0.038461538461538
To calculate the eigenvalues of the matrix x, we can perform the following operation.
Example 38
x =
1 2 5
4 6 6
6 5 7
>> eig(x)
ans =
14.645217647029696
−2.234341959325249
1.589124312295557
Introduction to MATLAB 19
Let us see how we can manipulate the eigenvector and the eigenvalues.
Example 39
>> [v,e] = eig(x)
v =
−0.345702432092625 −0.842635176101989 0.362970606773015
−0.637690615601249 0.017156405528112 −0.849621987304843
−0.688360739161774 0.538211499082772 0.382615756741668
e =
14.645217647029696 0 0
0 −2.234341959325249 0
0 0 1.589124312295557
To obtain the diagonal values, we can perform the following operation.
Example 40
>> diag(x)
ans =
1
6
7
The other subroutines under matrix operations are the approximation values of linear
expressions.
For example, to obtain the solution for Ax = B, we can perform the following operation.
Example 41
>> v=[1 2 3]; x=[1.428 7.926 4.856];
>> A = x/v
A =
1.428571428571429
2.428571428571428
2.642857142857143
>> B = [ 1 2 4];
>> A = B/v
>> A = B/v
20 Power Electronics with MATLAB
A =
1.214285714285714
>> A * B
ans =
1.214285714285714 2.428571428571428 4.857142857142857
>> A1 = v/B
A1 =
0.809523809523809
>> A1 * B
ans =
0.809523809523809 1.619047619047619 3.238095238095238
Example 42
x =
1 2 5
4 6 6
6 5 7
The submatrix would be
>> y = [x 10 * x; -x [1 0 0; 0 1 0; 0 0 1]]
y =
1 2 5 10 20 50
4 6 6 40 60 60
6 5 7 60 50 70
−1 −2 −5 1 0 0
−4 −6 −6 0 1 0
−6 −5 −7 0 0 1
Example 43
>> x(2,:) = []
x =
1 2 5
6 5 7
Other matrix generators include functions, such as eye, zeros and ones. The intellectual
properties of matrices include hilb, invhilb, magic, pascal, toeplitz, vander and Wilkinson.
There is also the whos command which will identify the set of variables in the workspace.
Example 44
>> whos
Name Size Bytes Class Attributes
A 1×1 8 double
A1 1×1 8 double
B 1×3 24 double
a 1×1 8 double
ans 1×3 24 double
b 1×1 8 double
c 1×1 8 double
e 3×3 72 double
g 1×1 8 double
u 1×1 8 double
v 1×3 24 double
x 2×3 48 double
y 6×6 288 double
z 1×1 8 double
1.4.4 Arrays
In MATLAB, the vector can be considered to be an array of single dimension and the
matrix an array of two dimensions. The variables are multidimensional.
The basic type of an array includes two types:
22 Power Electronics with MATLAB
Example 45
>> ones(8)
ans =
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
A single argument creates a square array.
Example 46
>> zeros(1,8)
ans =
0 0 0 0 0 0 0 0
The function ‘eye’ represents the identity matrix.
Example 47
>> eye(4)
ans =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
The function ‘random’ creates a Example 48 distributed random numbers.
Example 48
>> rand (3,8)
ans =
Introduction to MATLAB 23
Columns 1 through 3
0.814723686393179 0.913375856139019 0.278498218867048
0.905791937075619 0.632359246225410 0.546881519204984
0.126986816293506 0.097540404999410 0.957506835434298
Columns 4 through 6
0.964888535199277 0.957166948242946 0.141886338627215
0.157613081677548 0.485375648722841 0.421761282626275
0.970592781760616 0.800280468888800 0.915735525189067
Columns 7 through 8
0.792207329559554 0.035711678574190
0.959492426392903 0.849129305868777
0.655740699156587 0.933993247757551
These are the set of special arrays that are especially used by MATLAB functionalities.
Example 49
>> x = [2 4 5; 3 5 6; 5 6 7]
x =
2 4 5
3 5 6
5 6 7
To improve the dimension of the array, we do the following operation.
>> x(:, :, 2) = [ 1 2 3; 4 5 6; 7 8 9]
x(:, :, 1) =
2 4 5
3 5 6
5 6 7