This book provides a simple, easy-to-use introduction to MATLAB®, the programming environment popular with students, scientists and engineers and industries the world over as a tool for computation and simulation. The basic features of MATLAB are explained in a step-by-step manner with many examples to enable the reader to become proficient in using the language for a variety of applications.
Salient points:
Jaydeep Chakravorty obtained his BE in electrical and electronics engineering from Sikkim Manipal Institute of Technology, Majitar, Sikkim, and his ME in software engineering from Birla Institute of Technology, Mesra, Ranchi. He is currently an associate professor and the head of the Department of Electrical Engineering at Baddi University of Emerging Science and Technology, Solan, Himachal Pradesh. Prior to that, he was a faculty member at the University of Petroleum and Energy Studies, Dehradun. His areas of interests are electrical circuits and networks, power systems, fuzzy logic, neural networks, genetic algorithms and soft computing techniques. He has published papers in several journals and has presented papers in various national and international conferences.
PART-I
1 STARTING MATLAB 1.1 Introduction 1.2 MATLAB version 1.3 Starting MATLAB 1.3.1 Command window 1.3.1.1 Use of Semicolon and Comma 1.3.2 Command History Window 1.3.3 Workspace Window 1.3.4 Current Directory Window 1.4 MATLAB variables 1.5 Special Variables 1.6 Arithmetic Operators in MATLAB 1.7 Order of Precedence of MATLAB Operators 1.8 Formatting Commands in MATLAB 1.9 Advantages of MATLAB 1.10 Disadvantages of MATLAB 1.11 Summary Exercises
2 COMMON INBUILD MATLAB FUNCTIONS 2.1 Introduction 2.2 Commonly Used MATLAB Math Functions 2.3 Commonly Used MATLAB Trigonometric Functions 2.4 Commonly Used MATLAB Rounding Functions 2.5 Coordinate Functions in MATLAB 2.6 Specifier in MATLAB 2.7 MATLAB Functions for Characters and Strings 2.8 Keywords in MATLAB 2.9 Summary Exercises
3 WRITING PROGRAM IN M-FILE 3.1 Introduction 3.2 Opening an M-file 3.3 Writing Program in M-file 3.4 Saving the program written in M-file 3.5 Executing the program written in MATLAB 3.6 Making the MATLAB Program More Interactive 3.7 Use of ‘input()’, ‘disp()’ and ‘fprint()’ Commands 3.8 Summary Exercises
4 CREATING AN ARRAY IN MATLAB 4.1 Introduction 4.2 Creating one dimensional array 4.3 Accessing elements of the array 4.4 Accessing a block of element in the array 4.5 Array construction with constant spacing 4.6 Two dimensional array 4.7 The zeros, ones and eye commands 4.8 Array manipulation 4.9 Built in function for array handling 4.10 Some other operations with array 4.11 Summary Exercises
5 ARRAY MATHEMATICS 5.1. Introduction 5.2 Scalar and array operation 5.2.1 Addition operation 5.2.2 Subtraction operation 5.2.3 Multiplication operation 5.2.4 Right division operation 5.2.5 Left division operation 5.2.6 .^ operation 5.3 Array and array operation 5.3.1 Addition operation 5.3.2 Subtraction operation 5.3.3 Multiplication operation 5.3.4 Division operation 5.3.4.1 Left division operation 5.3.4.2 Right division operation 5.4 Element by element operation of array in MATLAB 5.4.1 Element by element multiplication operation 5.4.2 Element by element right division operation 5.4.3 Element by element left division operation 5.4.4 Element by element exponentiation operation 5.5 Some other commonly used MATLAB array functions 5.6 Some special matrices 5.7 Application of MATLAB in solving circuit problems 5.8 Summary Exercises
6 TWO-DIMENSIONAL PLOT 6.1 Introduction 6.2 Plot Command 6.3 Optional Commands in Plot Command 6.4 HOLD ON and HOLD OFF Command 6.5 colordef command 6.6 Grid command 6.7 label command 6.8 Title command 6.9 Text command 6.10 gtext command 6.11 Formatting the Text on the Graph 6.12 Legend Command 6.13 fplot command 6.14 ezplot command 6.15 Axis command 6.16 Subplot Command 6.17 Other Two Dimensional Plots 6.18 Special Graphs 6.18.1 Pie Chart 6.18.2 Pareto Chart 6.18.3 Bar chart 6.18.4 Horizontal Bar chart 6.18.5 Stairs Plot 6.18.6 Stem Plot 6.18.7 Histogram Plot 6.18.8 Polar Plot 6.18.9 Compass plot and feather plot 6.18.10 Rose Plot 6.19 Summary Exercises
7 THREE-DIMENSIONAL PLOT 7.1 Introduction 7.2 Three dimensional line plot 7.3 Three dimensional mesh and surface plot 7.4 Contour plot 7.5 Meshc plot 7.6 Meshz plot 7.7 Surfc plot 7.8 Surfl plot 7.9 Waterfall plot 7.10 Contour3 plot 7.11 Ribbon plot 7.12 Sphere plot 7.13 Cylinder plot 7.14 Bar3 plot 7.15 Pie3 plot 7.16 Stem3 plot 7.17 Summary Execise
8 RELATIONAL AND LOGICAL OPERATORS 8.1 Introduction 8.2 Relational operators in MATLAB 8.2.1 Greater than operator 8.2.2 Less than operator 8.2.3 Greater than equal to operator 8.2.4 Less than equal to operator 8.2.5 Equal to operator 8.2.6 Not equal to operator 8.3 Logical operators in MATLAB 8.3.1 AND operator 8.3.2 OR operator 8.3.3 NOT operator 8.3.4 XOR Operation 8.3.5 ALL Operator 8.3.6 ANY operator 8.3.7 FIND Operator 8.4 Summary Exercises
9 CONDITIONAL STATEMENTS 9.1 Introduction 9.2 Control Flow Statements in MATLAB 9.2.1 for loop 9.2.1.1 Nested for loop 9.2.1.2 Properties of for loop 9.2.2 while loop 9.2.2.1 Properties of while loop 9.2.3 if-else-end structure 9.2.3.1 Nested if-else-end structure 9.2.4 Switch-case structure 9.3 try-catch statement 9.4 lasterr 9.5 end statement 9.6 Break and continue command 9.7 Summary Exercises
10 FUNCTIONS 10.1 Introduction 10.2 Format of MATLAB function 10.3 Rules for writing function files 10.4 How to call a user defined function 10.5 Properties of function files 10.6 Concept of local and global variables 10.7 Persistent memory 10.8 Function inside a function 10.9 Inline function 10.10 Summary
11 POLYNOMIALS 11.1 Introduction 11.2 Representation of a polynomial in MATLAB 11.3 Polynomial functions 11.3.1 Roots command 11.3.2 Poly command 11.3.3 polyval function 11.3.4 polyvalm function 11.3.5 Addition and subtraction of polynomials 11.3.6 Multiplication of polynomials 11.3.7 Division of polynomials 11.3.8 Polynomial derivative 11.3.9 Residue function 11.4 Summary Exercises
12 INTERPOLATION AND CURVE FITTING 12.1 Introduction 12.2 Interpolation functions 12.2.1 Interp1 function 12.2.2 Interp2 function 12.2.3 Interpft function 12.2.4 spline function 12.2.5 griddata function 12.3 Curve Fitting 12.3.1 polyfit function 12.4 Summary Exercises
13 NUMERICAL ANALYSIS 13.1 Introduction 13.2 MATLAB functions 13.2.1 fzero function 13.2.2 fminbnd function 13.2.3 quad function 13.2.4 quadl function 13.2.5 quadv function 13.2.6 trapz function 13.2.7 cumtrapz function 13.3 Ordinary Differential Equations (ODE) 13.3.1 ODE functions in MATLAB 13.4 Summary Exercises
14 GRAPHICAL USER INTERFACES (GUI) IN MATLAB 14.1 Introduction 14.2 Creating a new GUI 14.3 Creating GUI having only one input from the user 14.4 Creating GUI having multiple inputs from the user 14.5 Other GUI templates 14.5.1 GUI with Uicontrols 14.5.2 GUI with axes and menu 14.6 Summary Exercises
PART-II
15 CONTROL SYSTEM TOOLBOX 15.1 Introduction 15.2 System representation 15.3 Representation of control system models in MATLAB 15.3.1 Transfer function model 15.3.2 State space model 15.3.3 Pole zero gain model 15.4 Conversion from one model to another 15.5 Adding time delay in the system 15.5.1 Discrete system 15.5.2 Linear system 15.6 Interconnection of linear models 15.7 Feedback connection in MATLAB 15.8 Obtaining transfer function from block diagram 15.9 Time domain and frequency response 15.9.1 Step response 15.9.2 Impulse response 15.9.3 Bode plot 15.9.4 Root locus plot 15.9.5 Nyquist plot 15.9.6 Polar plot 15.10 GUI for analyzing LTI system 15.10.1 Importing control system model into the GUI 15.10.2 Exporting control system model 15.11 Summary Exercises
16 SYMBOLIC MATH TOOLBOX 16.1 Introduction 16.2 Why to use this toolbox? 16.3 findsym command 16.4 subs command 16.5 Creating symbolic functions 16.6 Performing calculus operations 16.6.1 Differentiation 16.6.1.1 Partial differentiation 16.6.2 Integration 16.6.3 Limits 16.6.4 Summation 16.6.5 Taylor series 16.6.5.1 Taylortool GUI 16.7 Simplification of mathematical expression 16.7.1 Collect command 16.7.2 Expand command 16.7.3 Horner command 16.7.4 Factor command 16.7.5 Simplify command 16.8 Equation solving 16.9 Solving simultaneous equations 16.10 Solving single differential equation 16.11 Other mathematical functions 16.12 MuPAD 16.12.1 Writing expressions in MuPAD 16.12.2 Difference between MATLAB expression and MuPAD expression 16.12 Summary Exercises
17 FUZZY LOGIC TOOLBOX 17.1 Introduction 17.2 A Simple Example of to Demonstrate the use of Fuzzy Logic 17.3 Fuzzy Logic Toolbox 17.3.1 Membership Function Editor 17.3.2 Rule Editor 17.3.3 Rule Viewer 17.3.4 Surface Viewer 17.4 Summary Exercises
18 NEURAL NETWORK TOOLBOX 18.1 Introduction 18.2 Structure of neuron 18.3 Transfer functions 18.3.1 Hard limit transfer function 18.3.2 Linear transfer function 18.3.3 Log sigmoid transfer function 18.3.4 Positive linear transfer function 18.3.5 Triangular basis transfer function 18.3.6 Tan sigmoid transfer function 18.3.7 Radial basis transfer function 18.3.8 Satlin transfer function 18.3.9 Satlins transfer function 18.4 Representation of neurons 18.4.1 Representation of one layer networks 18.4.2 Representation of multi layer networks 18.5 Simulating networks in MATLAB 18.5.1 Simulation of static networks 18.5.2 Simulation of networks with delay 18.6 Perceptron 18.7 Simulation using neural network GUI 18.8 ADALINE 18.9 Linear system design 18.10 Backpropagation 18.10.1 Creating a feed forward networks 18.10.2 Method to initialize weights 18.10.3 Training of network 18.11 Self organizing networks 18.12 Self organizing maps 18.13 Summary Exercises
19 SIGNAL PROCESSING TOOLBOX 19.1 Introduction 19.2 Waveform functions in MATLAB 19.3 Filters 19.3.1 Characterization of digital filters 19.3.2 Filter coefficients and filter names 19.3.3 filtic command 19.3.4 Other functions of signal processing toolbox 19.4 Filter design 19.4.1 Butterworth filter design 19.4.2 Bessel filter design 19.4.3 Chebyshev type – I digital and analog filter design 19.4.4 Chebyshev type – I digital and analog filter design 19.4.5 Elleptic or Cauer digital filter design 19.5 Design of filter using filter builder GUI 19.6 Design of filter using fdatool 19.7 Summary Exercises
20 COMMUNICATION TOOLBOX 20.1 Introduction 20.2 Block diagram of communication system 20.3 Generation of random integer signal 20.3.1 wgn command 20.3.2 randsrc command 20.3.3 randint command 20.3.4 randerr command 20.4 Bit error and symbolic error rate 20.4.1 biterr command 20.4.2 symerr command 20.5 Modulation and Demodulation 20.5.1 Modulation and Demodulation using modem object 20.6 Communication channels 20.7 Bit error rate analysis tool (BERTool) 20.7.1 Theoretical method of generating BER data 20.7.2 Semianalytic method of generating BER data 20.8 Simulink model 20.9 Integrating BERTool and Simulink 20.10 Creating MATLAB function for use with BERTool Exercises
PART-III 21 INTRODUCTION TO SIMULINK 21.1 Introduction 21.2 Starting Simulink 21.3 A simple example 21.4 Solving differential Equation in Simulink 21.5 Digital electronics in Simulink 21.6 To model DC motor in Simulink Exercises
22 SIMPOWERSYSTEM MODEL 22.1 Introduction 22.2 SimPowerSystems Library 22.3 Building Circuits using Powerlib Library 22.4 Simulating Transients 22.5 Simulation of power system model Exercises
23 SOME APPLICATION PROBLEMS
Appendix A: List of some of the most common MATLAB commands Appendix B Solutions to odd problems of Chapter 23 Index