MATLAB Essentials – A First Course for Engineers and Scientists
William Bober
Contents
Preface ix
Acknowledgments xiii
Author .xv
1. Computer Programming with MATLAB for Engineers .1
1.1 Introduction .1
1.2 Computer Usage in Engineering 1
1.3 Mathematical Model .2
1.4 Computer Programming .3
1.5 Components of a Typical Desktop/Laptop Computer System .3
1.6 Overview of Programming Languages .5
1.7 Why MATLAB? .5
1.8 Programming Methodologies .6
1.9 MATLAB Programming Language .6
1.10 Building Blocks in Writing a Computer Program .7
1.11 Example Programs .7
2. MATLAB Fundamentals .9
2.1 Introduction .9
2.2 MATLAB’s Desktop 10
2.3 Constructing a Script (Program) in MATLAB 13
2.4 Variable Names and Types 18
2.5 Assignment Operator . 19
2.5.1 Arithmetic Operators 20
2.6 Some MATLAB Features, Commands, Special Items,
and Built-in Functions 21
2.6.1 Trigonometric and Other Useful Functions 21
2.6.1.1 Special Values .23
2.6.1.2 Trigonometric Functions 24
2.6.1.3 Inverse Trigonometric Functions . 24
2.6.1.4 Exponential, Square Root, and Error
Functions .25
2.6.1.5 Complex Numbers .26
2.6.2 Other Special Values .26
2.6.2.1 Other Useful MATLAB Functions 26
2.6.2.2 Colon Operator (:) .28
2.6.2.3 Preallocation of a Matrix 29vi Contents
2.7 MATLAB Output 30
2.7.1 The disp Command . 31
2.7.2 The fprintf Command 31
2.7.3 Printing to a File 32
2.8 Simple Plot Commands .34
2.8.1 Linear Plot .34
2.9 Loops 36
2.9.1 The for Loop .36
2.9.2 The While Loop 43
2.10 Input 50
2.10.1 The Load Command .50
2.10.2 The dlmread Command 52
2.10.3 fscanf Command 52
2.10.4 The input Command .54
2.11 More on MATLAB Graphics .55
2.11.1 The figure Command 55
2.11.2 Multiple Plots .57
2.11.3 The hold on Command 59
2.11.4 Plotyy Command 62
2.11.5 The subplot Command 63
2.11.6 Bar Charts .63
2.11.7 Pie Charts 65
2.11.8 Greek Letters and Mathematical Symbols .68
2.11.9 Interactively Annotating Plots .69
2.11.10 Saving Plots 69
References .80
3. Conditional Operators, Built-in Functions with Vector
Arguments, MATLAB ’s Interp1 Function, and Some Scalar and
Vector Operations .81
3.1 Introduction . 81
3.2 Conditional Operators and Alternate Paths . 81
3.2.1 The if Command Provides Two Alternate Paths 81
3.2.2 The if-elseif-else Command Provides More
than Two Alternate Paths .83
3.2.3 The break Command 85
3.2.4 The switch Command 89
3.2.5 MATLAB’s menu Function .90
3.3 Working with Built-in Functions with Vector Arguments .92
3.4 MATLAB’s interp1 Function .93
3.5 Some Scalar and Vector Operations .96
3.5.1 Addition of a Scalar and a Vector 96
3.5.2 Multiplication of a Scalar Times a Vector .96
3.5.3 Addition and Subtraction of Two Vectors of the
Same Length .96Contents vii
3.5.4 Element-by-Element Operations 96
3.5.5 Operation of Two Vector Functions 98
4. Self-Written Functions and MATLAB ’s fminbnd Function . 105
4.1 Introduction . 105
4.2 Self-Written Function 105
4.3 Anonymous Functions . 110
4.4 MATLAB’s fminbnd 113
References .122
5. Working with Characters and Strings .123
5.1 Introduction .123
5.2 MATLAB’s textscan Function . 127
6. Roots of Algebraic and Transcendental Equations . 131
6.1 Introduction . 131
6.2 Search Method . 132
6.3 Bisection Method 133
6.4 MATLAB’s fzero Function . 134
6.5 MATLAB’s roots Function 139
References . 152
7. System of Algebraic, Linear Equations 153
7.1 Introduction . 153
7.2 System of Algebraic, Linear Equations 153
7.2.1 MATLAB’s inv Function 154
7.2.2 Gauss-Elimination Method 154
7.3 Treatment of Large Systems of Algebraic, Linear Equations 156
7.4 A Resistive Circuit Problem . 159
7.5 Gauss Elimination . 161
7.6 Number of Solutions . 162
References . 167
8. Curve Fitting 169
8.1 Introduction . 169
8.2 MATLAB’s Curve-Fitting Functions 169
8.3 Curve Fitting with the Exponential Function . 174
8.4 Cubic Splines 178
8.4.1 MATLAB’s Cubic Spline Curve-Fitting Function 179
9. Numerical Integration . 187
9.1 Introduction . 187
9.2 Numerical Integration and Simpson’s Rule 187
9.3 Improper Integrals 190viii Contents
9.4 MATLAB’s integral Function . 190
9.5 MATLAB’s integral2 Function . 194
Reference .204
10. Numerical Integration of Ordinary Differential Equations .205
10.1 Introduction .205
10.2 Initial Value Problem and MATLAB’s Ordinary
Differential Equations Function .206
Reference .226
11. Boundary Value Problems of Ordinary Differential Equations 227
11.1 Introduction .227
11.2 Difference Formulas .227
References .235
Appendix: Greek Letters and Special Characters in MATLAB Plots . 237
Review Answers 241
Index .
كلمة سر فك الضغط : books-world.net
The Unzip Password : books-world.net
تحميل
يجب عليك التسجيل في الموقع لكي تتمكن من التحميل
تسجيل | تسجيل الدخول