Essential MATLAB for Engineers and Scientists, Fourth Edition

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

The essential guide to MATLAB as a problem solving tool This text presents MATLAB both as a mathematical tool and a programming language, giving a concise and easy to master introduction to its potential and power. The fundamentals of MATLAB are illustrated throughout with many examples from a wide range of familiar scientific and engineering areas, as well as from everyday life. The new edition has been updated to include coverage of Symbolic Math and SIMULINK. It also adds new examples and applications, and uses the most recent release of Matlab. ?· New chapters on Symbolic Math and SIMULINK provide complete coverage of all the functions available in the student edition of Matlab.* New: more exercises and examples, including new examples of beam bending, flow over an airfoil, and other physics-based problems* New: A bibliography provides sources for the engineering problems and examples discussed in the text ?· A chapter on algorithm development and program design ?· Common errors and pitfalls highlighted ?· Extensive teacher support on http://textbooks.elsevier.com: solutions manual, extra problems, multiple choice questions, PowerPoint slides ?· Companion website for students providing M-files used within the book

Author(s): Brian Hahn, Dan Valentine
Edition: 4
Year: 2009

Language: English
Pages: 427

Contents......Page 3
Preface......Page 14
ACKNOWLEDGMENTS......Page 15
PART 1: Essentials......Page 16
1 Introduction......Page 18
1.1.1 Arithmetic......Page 20
1.1.2 Variables......Page 22
1.1.3 Mathematical functions......Page 23
1.1.5 Vectors......Page 24
1.1.6 Linear equations......Page 26
1.1.8 Help......Page 27
1.1.9 Additional features......Page 28
1.2 THE MATLAB DESKTOP......Page 30
1.3.1 Cut and paste......Page 31
1.3.2 Saving a program: script files......Page 33
1.3.3 A program in action......Page 34
EXERCISES......Page 35
CHAPTER EXERCISES......Page 36
2.1 VARIABLES......Page 38
2.2 THE WORKSPACE......Page 39
2.2.1 Adding commonly used constants to the workspace......Page 40
EXERCISES......Page 41
2.3.2 Initializing vectors: The colon operator......Page 42
2.3.5 Subscripts......Page 43
2.3.6 Matrices......Page 44
2.4 VERTICAL MOTION UNDER GRAVITY......Page 45
2.5 OPERATORS, EXPRESSIONS, AND STATEMENTS......Page 47
2.5.1 Numbers......Page 48
2.5.4 Operator precedence......Page 49
2.5.5 The colon operator......Page 50
2.5.7 Arithmetic operations on arrays......Page 51
2.5.8 Expressions......Page 52
2.5.9 Statements......Page 53
2.5.11 Formula vectorization......Page 54
EXERCISES......Page 55
2.6.1 The disp statement......Page 57
2.6.2 The format command......Page 58
2.7 REPEATING WITH for......Page 60
2.7.1 Square roots with Newton’s method......Page 61
2.7.3 Limit of a sequence......Page 62
2.7.4 The basic for construct......Page 63
2.7.7 Avoid for loops by vectorizing!......Page 65
EXERCISES......Page 67
2.8.1 The one-line if statement......Page 68
EXERCISES......Page 69
2.8.2 The if-else construct......Page 70
2.8.4 elseif......Page 71
2.8.5 Logical operators......Page 72
2.8.6 Multiple ifs versus elseif......Page 73
2.8.7 Nested ifs......Page 74
2.8.9 The switch statement......Page 75
2.9 COMPLEX NUMBERS......Page 76
2.10.1 fprintf......Page 78
2.10.2 Output to a disk file with fprintf......Page 79
2.11.1 Variables, functions, and scripts with the same name......Page 80
2.11.2 The input statement......Page 81
2.12 PROGRAMMING STYLE......Page 82
SUMMARY......Page 83
CHAPTER EXERCISES......Page 86
3 Program Design and Algorithm Development......Page 92
3.1 THE PROGRAM DESIGN PROCESS......Page 93
3.1.1 The projectile problem......Page 95
3.2 STRUCTURE PLAN EXAMPLES......Page 100
3.2.1 Quadratic equation......Page 101
CHAPTER EXERCISES......Page 103
4.1 COMMON FUNCTIONS......Page 106
4.2.1 The load and save commands......Page 111
4.2.4 Exporting and importing binary data......Page 112
4.2.6 *Low-level file I/O functions......Page 113
SUMMARY......Page 118
CHAPTER EXERCISES......Page 119
5 Logical Vectors......Page 122
5.1.1 Discontinuous graphs......Page 123
5.1.2 Avoiding division by zero......Page 124
5.1.3 Avoiding infinity......Page 125
5.1.4 Counting random numbers......Page 126
5.1.5 Rolling dice......Page 127
5.2 LOGICAL OPERATORS......Page 128
5.2.1 Operator precedence......Page 129
5.2.3 Logical operators and vectors......Page 130
5.3 SUBSCRIPTING WITH LOGICAL VECTORS......Page 131
5.4 LOGICAL FUNCTIONS......Page 132
5.4.1 Using any and all......Page 133
LADDERS......Page 134
CHAPTER EXERCISES......Page 137
6 Matrices of Numbers and Arrays of Strings......Page 140
6.1.1 A concrete example......Page 141
6.1.3 Subscripts......Page 142
6.1.5 The colon operator......Page 143
6.1.7 Deleting rows and columns......Page 147
6.1.8 Elementary matrices......Page 148
6.1.9 Specialized matrices......Page 149
6.1.10 Using MATLAB functions with matrices......Page 150
6.1.12 Array (element-by-element) operations on matrices......Page 151
6.1.15 Vectorizing nested fors: Loan repayment tables......Page 152
6.2.1 Multiplication......Page 155
6.2.2 Exponentiation......Page 157
6.4.1 Input......Page 158
6.4.4 ASCII codes: double and char......Page 159
6.4.7 Other string functions......Page 161
6.5 *TWO-DIMENSIONAL STRINGS......Page 162
6.6.1 Error trapping with eval and lasterr......Page 163
6.6.2 eval with try...catch......Page 164
CHAPTER EXERCISES......Page 165
7.1 BASIC TWO-DIMENSIONAL GRAPHS......Page 168
EXERCISES......Page 169
7.1.2 Multiple plots on the same axes......Page 170
7.1.4 Axis limits......Page 171
7.1.5 Multiple plots in a figure: subplot......Page 172
7.1.8 Logarithmic plots......Page 174
7.1.9 Polar plots......Page 175
functions: fplot......Page 176
7.2.1 The plot3 function......Page 177
7.2.3 Mesh surfaces......Page 178
7.2.4 Contour plots......Page 180
7.2.6 Visualizing vector fields......Page 182
7.2.7 Matrix visualization......Page 183
7.2.8 3D graph rotation......Page 184
7.2.9 Other graphics functions......Page 185
SUMMARY......Page 193
CHAPTER EXERCISES......Page 194
8.1.1 Binomial coefficient......Page 200
8.1.2 Update processes......Page 201
8.2.1 A guessing game......Page 203
8.2.2 The while statement......Page 204
8.2.3 Doubling time of an investment......Page 205
8.2.4 Prime numbers......Page 206
8.2.5 Projectile trajectory......Page 207
8.2.6 break......Page 209
8.2.7 Menus......Page 210
SUMMARY......Page 211
CHAPTER EXERCISES......Page 212
9.1 SYNTAX ERRORS......Page 216
9.2 LOGIC ERRORS......Page 217
9.3 ROUNDING ERROR......Page 218
CHAPTER EXERCISES......Page 219
10.1 INLINE OBJECTS: HARMONIC OSCILLATORS......Page 222
10.2 FUNCTION M-FILES: NEWTON’S METHOD REVISITED......Page 224
10.3 BASIC RULES......Page 225
10.3.4 Improving M-file performance with the profiler......Page 230
10.4 FUNCTION HANDLES......Page 231
10.5 COMMAND/FUNCTION DUALITY......Page 232
10.6 FUNCTION NAME RESOLUTION......Page 233
10.7.1 Debugging a script......Page 234
10.8 RECURSION......Page 236
SUMMARY......Page 237
CHAPTER EXERCISES......Page 239
11.1 UPDATE PROCESSES......Page 242
11.1.1 Unit time steps......Page 243
11.1.2 Non–unit time steps......Page 245
11.1.3 Using a function......Page 246
11.2.1 A random walk......Page 248
11.3 *SORTING......Page 250
11.3.1 Bubble Sort......Page 251
11.3.2 MATLAB’s sort......Page 252
11.4 *STRUCTURES......Page 253
11.5.1 Assigning data to cell arrays......Page 255
11.5.3 Using cell arrays......Page 257
11.5.4 Displaying and visualizing cell arrays......Page 258
SUMMARY......Page 259
12.1 HANDLE GRAPHICS......Page 260
12.1.1 Getting handles......Page 261
12.1.2 Changing graphics object properties......Page 262
12.1.3 A vector of handles......Page 263
12.1.5 Parenting......Page 264
12.1.6 Positioning figures......Page 265
12.2.1 Plot edit mode......Page 266
12.2.2 Property Editor......Page 267
12.3 ANIMATION......Page 268
12.3.1 Animation with Handle Graphics......Page 269
12.4 COLORMAPS......Page 271
12.4.1 Surface plot color......Page 273
12.5 LIGHTING AND CAMERA......Page 274
12.6.2 Printing a graph......Page 275
SUMMARY......Page 276
CHAPTER EXERCISES......Page 277
13.1 BASIC STRUCTURE OF A GUI......Page 278
13.2 A FIRST EXAMPLE: GETTING THE TIME......Page 279
13.3 NEWTON’S METHOD YET AGAIN......Page 283
13.4 AXES ON A GUI......Page 286
13.5 ADDING COLOR TO A BUTTON......Page 287
SUMMARY......Page 288
PART 2: Applications......Page 290
14 Dynamical Systems......Page 292
14.1 CANTILEVER BEAM......Page 293
14.2 ELECTRIC CURRENT......Page 294
14.3 FREE FALL......Page 296
14.4 PROJECTILE WITH FRICTION......Page 306
SUMMARY......Page 309
CHAPTER EXERCISES......Page 310
15.1 RANDOM NUMBER GENERATION......Page 312
15.2 FLIPPING COINS......Page 313
15.3 ROLLING DICE......Page 314
15.5 A RANDOM WALK......Page 315
15.6 TRAFFIC FLOW......Page 317
SUMMARY......Page 320
CHAPTER EXERCISES......Page 321
16.1 LESLIE MATRICES: POPULATION GROWTH......Page 324
16.2.1 A random walk......Page 328
16.3 LINEAR EQUATIONS......Page 330
16.3.1 MATLAB’s solution......Page 331
16.3.3 Overdetermined systems......Page 332
16.3.5 Ill-conditioned systems......Page 333
16.3.6 Matrix division......Page 334
16.4 SPARSE MATRICES......Page 335
CHAPTER EXERCISES......Page 338
17.1.1 Newton’s method......Page 340
17.1.2 The Bisection method......Page 343
17.1.3 The fzero and roots functions......Page 344
17.2.1 The Trapezoidal rule......Page 345
17.2.2 Simpson’s rule......Page 346
17.3 NUMERICAL DIFFERENTIATION......Page 347
17.3.1 The diff function......Page 348
17.4.1 Euler’s method......Page 349
17.4.2 Example: Bacteria colony growth......Page 350
17.4.3 Alternative subscript notation......Page 351
17.4.4 A predictor-corrector method......Page 353
17.6.1 A single differential equation......Page 354
17.6.2 Systems of differential equations: Chaos......Page 355
17.6.3 Passing additional parameters to an ODE solver......Page 358
17.7.1 Heat conduction......Page 359
17.8 OTHER NUMERICAL METHODS......Page 363
CHAPTER EXERCISES......Page 364
A.3 GRAPHICS......Page 368
A.4 if AND switch......Page 369
A.5 for AND while......Page 370
A.7 load/save......Page 371
A.8 VECTORS AND MATRICES......Page 372
Appendix B: Operators......Page 374
C.1.2 Files and the operating system......Page 376
C.3 MATLAB PROGRAMMING TOOLS......Page 377
C.4.3 Matrix manipulation......Page 378
C.5 MATHEMATICAL FUNCTIONS......Page 379
C.8 POLYNOMIAL FUNCTIONS......Page 380
C.13 2D GRAPHICS......Page 381
C.15 GENERAL......Page 382
Appendix D: ASCII Character Codes......Page 384
CHAPTER 2......Page 385
CHAPTER 3......Page 389
CHAPTER 5......Page 391
CHAPTER 8......Page 392
CHAPTER 10......Page 394
CHAPTER 15......Page 395
CHAPTER 17......Page 396
INDEX......Page 398