# A Guide to MATLAB for Beginners and Experienced Users ebook代购

 Contents at a Glance( k: Q" c1 M; H' _) H" w Preface page xiii  V5 N/ ?# l, x, b 1 Getting Started 1* J8 H1 O4 G2 F3 x  Q* S/ R' r' | 2 MATLAB Basics 8 3 Interacting with MATLAB 31 Practice Set A: Algebra and Arithmetic 48 4 Beyond the Basics 50 5 MATLAB Graphics 67. i  a: F( J# x7 c! m, z) } Practice Set B: Calculus, Graphics, and Linear Algebra 86; n, l. @8 \6 p1 I9 v6 N 6 M-Books 917 s* d; V) S/ V) I, L 7 MATLAB Programming 101/ u* s3 s1 x+ I4 k 8 SIMULINK and GUIs 121/ l/ C" H7 D* I 9 Applications 136: W5 f! `! ~) k& b/ J- D/ w Practice Set C: Developing Your MATLAB Skills 2048 _3 Z6 o0 L! M3 p9 A 10 MATLAB and the Internet 214 11 Troubleshooting 218 Solutions to the Practice Sets 235% [* \\$ t( C; F5 G Glossary 2999 X3 @3 y) }9 Q! G& ~ Index 317 v9 [! r  G5 e5 v7 y8 w, b# c ; c! i: d6 m! u# N: Z Contents  E0 h1 d, H9 v# ?0 c+ V& I Preface page xiii 1 Getting Started 11 V, q9 n" H, [0 C0 \ Platforms and Versions 1( K7 v" u! k4 x; Z* y' M+ E7 }/ S Installation and Location 2; k8 U+ |' m! Z( U\$ d+ Y' A Starting MATLAB 21 U+ ^6 v' u7 y  x- w  N Typing in the Command Window 34 p( r3 F4 k/ K, `- l Online Help 4 Interrupting Calculations 5 MATLAB Windows 6 Ending a Session 7+ g/ }8 a3 |# a2 r+ v! k! K- k+ p 2 MATLAB Basics 8 Input and Output 8! x% u4 P& W  A9 s" @ Arithmetic 8 Algebra 10 Symbolic Expressions, Variable Precision, and Exact. v. s) w! g& Z Arithmetic 11 Managing Variables 13% F! c. p  c- w  J) F7 x6 X Errors in Input 14( I, ?9 q7 e\$ ]' K. D6 \ Online Help 152 y/ Q2 X2 K" b5 T\$ [ Variables and Assignments 16 Solving Equations 17 Vectors and Matrices 20 Vectors 212 b  o2 f  c: a& P Matrices 23% Y+ j* V5 G! y* j\$ ? Suppressing Output 247 u' J\$ s. l) n7 L- b1 r, L Functions 24 vii" T( O) A\$ b8 ~: R* E viii Contents- S: P! u; a! f- I/ ?7 ~ Built-in Functions 24 User-Defined Functions 25 Graphics 26\$ S3 K1 j3 c/ R' y) _+ u8 t  d& A Graphing with ezplot 26 Modifying Graphs 27 Graphing with plot 289 e1 ^+ {+ t% s- y6 s  D Plotting Multiple Curves 30 3 Interacting with MATLAB 31 The MATLAB Interface 31  H0 t* l6 Y# K; F7 i The Desktop 31 Menu and Tool Bars 33; m- N\$ Z3 F5 R( u The Workspace 33  o9 ?- Q- }) Q6 |" v9 G+ ^2 i The Working Directory 34( a7 c, K1 G& L( e* p Using the Command Window 35 M-Files 36( _4 m' [1 x6 _ Script M-Files 37, ]& j1 n+ ?4 p6 H( ~& z5 r Function M-Files 39. O& d7 E1 t3 P# Z Loops 41% M! X' U) k* U0 u: v+ s" m, L Presenting Your Results 41 Diary Files 42" U& t( @* V4 f Presenting Graphics 43* `( y0 ~( D6 J" J0 ] Pretty Printing 453 ]+ N) n4 \& v1 p A General Procedure 457 u( `" B, P1 f0 v Fine-Tuning Your M-Files 46 Practice Set A: Algebra and Arithmetic 48 4 Beyond the Basics 50 Suppressing Output 509 P& A- G" F9 Y  _1 _% r Data Classes 51 String Manipulation 537 ]8 L4 C+ h" D' C Symbolic and Floating Point Numbers 53 Functions and Expressions 54 Substitution 56: e: j# f1 G9 q; B4 M: c More about M-Files 564 r- s: p9 L3 ^* K Variables in Script M-Files 56, Y6 d/ o, |* G Variables in Function M-Files 57. k- W: E0 q* g6 \7 w- Y6 c% I Structure of Function M-Files 57 Contents ix& {" X2 ?  m' U9 x3 y Complex Arithmetic 587 f! `5 ~# x. ]4 t; D More on Matrices 592 m- G& k0 M* |8 o0 a' S Solving Linear Systems 60) v: R7 e0 k: h; D Calculating Eigenvalues and Eigenvectors 605 P9 `: _1 u\$ b/ F( [ Doing Calculus withMA TLAB 617 ?0 }, f1 n  M2 r; N6 c Differentiation 61: H. L2 C* m4 \9 e7 F4 Y# o Integration 624 F( Z# u5 m4 }1 @7 H5 V Limits 63 Sums and Products 64 Taylor Series 65" W# S3 V, r3 _! g- k3 \, Z Default Variables 65- d1 |2 q- d" t% R7 L) ~6 f/ F- l 5 MATLAB Graphics 67 Two-Dimensional Plots 67; B5 z3 G# H/ \; H3 d Parametric Plots 67\$ V  x- y' ^( T% L8 K: Y& q% F Contour Plots and Implicit Plots 69 Field Plots 717 }. o: q; s. t) T& O Three-Dimensional Plots 72 Curves in Three-Dimensional Space 72 Surfaces in Three-Dimensional Space 732 i1 A; H6 y- _( E* Y0 l' K, p Special Effects 75* p\$ g% Q" O+ Z; d8 W; ]; | Combining Figures in One Window 76; g0 H* d4 B, i7 q! f\$ { Animations 77+ m- Z+ F/ l# e" U Customizing and Manipulating Graphics 78 Change of Viewpoint 80  x3 Z' N# H# B. V Change of Plot Style 80) w1 k8 Q) H: ?( Y\$ Y Full-Fledged Customization 825 i+ C' V1 C; z8 @ Quick Plot Editing in the Figure Window 84/ B7 r8 n5 v7 a; s2 j& s. X7 c( `* U7 i Sound 85 Practice Set B: Calculus, Graphics, and Linear Algebra 868 l8 {. W3 Z+ t/ B& T 6 M-Books 91 Enabling M-Books 92; p1 C% _& C% _5 f- M6 `5 x4 O Starting M-Books 93* X7 M& H, r2 I% x) X/ | Working withM-Books 95/ ]% w4 t. C, N& h* q: T) R Editing Input 95, \' v! H+ ?; Y1 G. N& g& g5 k The Notebook Menu 96 x Contents M-Book Graphics 97* L, D/ Y2 K# F8 a5 _: V7 W, n More Hints for Effective Use of M-Books 98 A Warning 99 7 MATLAB Programming 101 Branching 101* ?; |+ I6 H5 |+ F6 \ Branching with if 102+ a' y7 U( v, A9 t4 H: Z\$ C Logical Expressions 104 Branching with switch 108" r: J) z# `3 {/ \0 n More about Loops 109 Open-Ended Loops 110 Breaking from a Loop 111 Other Programming Commands 112" i3 i' x: m2 Y4 [ Subfunctions 112 Commands for Parsing Input and Output 1123 P8 a! w% g& r( a" J6 O% I+ Q User Input and Screen Output 114 Evaluation 116 Debugging 1171 l# F\$ E1 d; ]% H Interacting withth e Operating System 118 Calling External Programs 118 File Input and Output 1199 m( h' V, w+ j7 q, c\$ p 8 SIMULINK and GUIs 121 SIMULINK 121! d& H! ]' S; X% F Graphical User Interfaces (GUIs) 127! `: w# s7 O5 J* X\$ j2 P* H GUI Layout and GUIDE 1271 a6 L! e4 c0 g: k Saving and Running a GUI 130 GUI Callback Functions 132 9 Applications 136 Illuminating a Room 1374 K2 ^) T9 K& E- R. S  S One 300-Watt Bulb 137 Two 150-Watt Bulbs 138 Three 100-Watt Bulbs 143: x" |" ]1 S5 k- ~ Mortgage Payments 145 Monte Carlo Simulation 149 Population Dynamics 156& d6 a! s# n8 z) n: L Exponential Growthand Decay 157 Contents xi# B% v( H1 S( B LogisticGrowth1598 f5 W2 O& b0 y Rerunning the Model with SIMULINK 166 Linear Economic Models 168* ~0 \0 X+ ^& U2 G' a9 l+ t Linear Programming 173 The 360? Pendulum 180' s; E2 J; S7 N Numerical Solution of the Heat Equation 184 A Finite Difference Solution 1854 n6 V" b% Y  X( o6 u5 {' u5 T+ F The Case of Variable Conductivity 1891 O3 g% z5 V* y5 N) M1 p A SIMULINK Solution 1916 I4 ]8 R8 I& ^" z: d2 q Solution with pdepe 194 A Model of Traffic Flow 1969 F/ R4 w* h) P8 \3 f3 f Practice Set C: Developing Your MATLAB Skills 204 10 MATLAB and the Internet 2143 o. h( l& ~, N/ Y( F# @. b6 \ MATLAB Help on the Internet 214# |7 _) N8 W% K Posting MATLAB Programs and Output 215: E% z4 c2 |  \7 G3 X M-Files, M-Books, Reports, and HTML Files 215 Configuring Your Web Browser 216 Microsoft Internet Explorer 216/ H- O" l- P  k4 g: p- s Netscape Navigator 216 11 Troubleshooting 218 Common Problems 218 Wrong or Unexpected Output 218# v  W0 ^/ @: C, P; _9 w" C  z! ^. f Syntax Error 220+ W% t/ j+ @5 {6 z' @) Y" _ Spelling Error 2234 X& F0 `2 M& w) z# L; k Error Messages When Plotting 223 A Previously Saved M-File Evaluates Differently 224 Computer Won’t Respond 226 The Most Common Mistakes 226 Debugging Techniques 227 Solutions to the Practice Sets 235 Practice Set A 235 Practice Set B 246. v6 p2 i6 Q' e, V  a7 Y Practice Set C 266 xii Contents( s! e2 {* }- d6 R: ?. Q8 z Glossary 299 MATLAB Operators 300" c2 _0 o3 q. W. s5 L; h! o+ [ Built-in Constants 301 Built-in Functions 302 MATLAB Commands 3037 y% X. |1 A# w/ B6 T1 A Graphics Commands 309  O* ?1 I0 h\$ p0 v' s% R. @ MATLAB Programming 313* `\$ r" W! z1 T! y9 s/ e Index 317 indicates an advanced chapter or section that can be skipped on a first reading.+ a& H) j/ y, H\$ A Preface That statement encapsulates the view of The MathWorks, Inc., the developer of MATLAB . MATLAB 6 is an ambitious program. It contains hundreds of commands to do mathematics. You can use it to graph functions, solve equations,! ^7 n\$ v  n+ b- g& M2 J\$ ] perform statistical tests, and do much more. It is a high-level programming language that can communicate with its cousins, e.g., FORTRAN and C. You) T) Q/ w9 W' @7 _ can produce sound and animate graphics. You can do simulations and modeling (especially if you have access not just to basic MATLAB but also to its4 c4 Y' ]& L\$ P2 v& N5 ?, Z/ y accessory SIMULINK ). You can prepare materials for export to the World& c" W: ~- p5 M* r Wide Web. In addition, you can use MATLAB, in conjunction withth e word processing and desktop publishing features of Microsoft Word , to combine mathematical computations with text and graphics to produce a polished, integrated, and interactive document. A program this sophisticated contains many features and options. There are literally hundreds of useful commands at your disposal. The MATLAB help documentation contains thousands of entries. The standard references, whether the MathWorks User’s Guide for the product, or any of our competitors,5 l4 d6 i# p; N: e6 L1 u contain myriad tables describing an endless stream of commands,6 }6 \- f3 \; s\$ P options, and features that the user might be expected to learn or access.% t\$ Y\$ G9 ~& B MATLAB is more than a fancy calculator; it is an extremely useful and versatile tool. Even if you only know a little about MATLAB, you can use it# h! z  ^- ^  v\$ a to accomplish wonderful things. The hard part, however, is figuring out which of the hundreds of commands, scores of help pages, and thousands of items of documentation you need to look at to start using it quickly and effectively. That’s where we come in. xiii xiv Preface7 W6 t9 [4 x4 Y; a+ L- i& v Why We Wrote This Book The goal of this book is to get you started using MATLAB successfully and quickly. We point out the parts of MATLAB you need to know without overwhelming\$ c. Z& O" C0 p' @ you with details. We help you avoid the rough spots. We give you7 n" V! R+ j1 P! R" H! u: B3 ~ examples of real uses of MATLAB that you can refer to when you’re doing your own work. And we provide a handy reference to the most useful features of MATLAB. When you’re finished reading this book, you will be able to use MATLAB effectively. You’ll also be ready to explore more of MATLAB on your own. You might not be a MATLAB expert when you finish this book, but you' O8 `. H7 D' _( z will be prepared to become one — if that’s what you want. We figure you’re probably more interested in being an expert at your own specialty, whether that’s finance, physics, psychology, or engineering. You want to use MATLAB, u4 [1 }/ Z& a; e8 [8 B" f the way we do, as a tool. This book is designed to help you become a proficient2 s6 N" h9 b7 z7 j: Z: V\$ T MATLAB user as quickly as possible, so you can get on withth e business at/ A, l7 J8 m) q/ O1 g hand.0 ]  C8 w0 G; X6 j( V3 I. ?# Z Who Should Read This Book This book will be useful to complete novices, occasional users who want to sharpen their skills, intermediate or experienced users who want to learn about the new features of MATLAB 6 or who want to learn how to use# f5 J. N7 P( F  m+ u SIMULINK, and even experts who want to find out whether we know anything they don’t. You can read through this guide to learn MATLAB on your own. If your employer (or your professor) has plopped you in front of a computer with MATLAB and told you to learn how to use it, then you’ll find the book particularly+ }8 e5 _: @, R3 Y3 ~0 D useful. If you are teaching or taking a course in which you want to use MATLAB as a tool to explore another subject — whether in mathematics, science, engineering, business, or statistics — this book will make a perfect supplement. As mentioned, we wrote this guide for use with MATLAB 6. If you plan to continue using MATLAB 5, however, you can still profit from this book.  K7 B9 X\$ I, j Virtually all of the material on MATLAB commands in this book applies to bothversions . Only a small amount of material on the MATLAB interface, found mainly in Chapters 1, 3, and 8, is exclusive to MATLAB 6. Preface xv How This Book Is Organized In writing, we drew on our experience to provide important information as quickly as possible. The book contains a short, focused introduction to- K& x9 S% `! `9 G  r/ h MATLAB. It contains practice problems (withcomplete solutions) so you can" @# ^( u) U- G& F& n+ U test your knowledge. There are several illuminating sample projects that show you how MATLAB can be used in real-world applications, and there is an entire! g4 `4 O( e" Q& a, p7 [& F chapter on troubleshooting. The core of this book consists of about 75 pages: Chapters 1–4 and the beginning of Chapter 5. Read that much and you’ll have a good grasp of the fundamentals of MATLAB. Read the rest — the remainder of the Graphics chapter as well as the chapters on M-Books, Programming, SIMULINK and GUIs, Applications, MATLAB and the Internet, Troubleshooting, and the Glossary — and you’ll know enoughto do a great deal withMA TLAB. Here is a detailed summary of the contents of the book. Chapter 1, Getting Started, describes how to start MATLAB on different5 A- k# X7 x\$ G& H: ]. r platforms. It tells you how to enter commands, how to access online help, how to recognize the various MATLAB windows you will encounter, and how to exit the application.7 o! z0 B7 D+ D( } Chapter 2, MATLABB asics, shows you how to do elementary mathematics9 q1 T9 O, S4 h2 u using MATLAB. This chapter contains the most essential MATLAB commands.+ ^4 _, V6 Y" J( m) F  n: A Chapter 3, Interacting with MATLAB, contains an introduction to the MATLAB Desktop interface. This chapter will introduce you to the basic window features of the application, to the small program files (M-files) that you4 ?" L* T5 K* j. i& x5 \ will use to make most effective use of the software, and to a simple method# G/ B. @" X0 ^ (diary files) of documenting your MATLAB sessions. After completing this chapter, you’ll have a better appreciation of the breadth described in the quote. \% ^\$ t" ^/ w/ w that opens this preface. Practice Set A, Algebra and Arithmetic, contains some simple problems for: F: h4 I. I& D# H, {- t9 O practicing your newly acquired MATLAB skills. Solutions are presented at! `! V3 M: Z* C% e the end of the book.\$ Z( T; `7 l3 `1 N7 u# P4 ? Chapter 4, Beyond the Basics, contains an explanation of the finer points that are essential for using MATLAB effectively. Chapter 5, MATLABGraphics , contains a more detailed look at many of) Y5 F4 }0 Y9 ]: K9 F7 p( F the MATLAB commands for producing graphics. Practice Set B, Calculus, Graphics, and Linear Algebra, gives you another+ ]7 n; U\$ W8 z! \8 `+ W5 u+ l chance to practice what you’ve just learned. As before, solutions are provided at the end of the book. xvi Preface Chapter 6, M-Books, contains an introduction to the word processing and9 @6 z( D* W  \6 S9 F: W desktop publishing features available when you combine MATLAB with Microsoft Word. Chapter 7, MATLABProgramming , introduces you to the programming features of MATLAB. This chapter is designed to be useful both to the novice: Y& Y% c\$ T( j8 j4 O" W% J programmer and to the experienced FORTRAN or C programmer.* t: U2 B7 O( h  |+ d5 x: w+ @ Chapter 8, SIMULINK and GUIs, consists of two parts. The first part describes the MATLAB companion software SIMULINK, a graphically oriented package for modeling, simulating, and analyzing dynamical systems. Many of the calculations that can be done with MATLAB can be done equally well with SIMULINK. If you don’t have access to SIMULINK, skip this part of Chapter 8. The second part contains an introduction to the construction and deployment of graphical user interfaces, that is, GUIs, using MATLAB. Chapter 9, Applications, contains examples, from many different fields, of solutions of real-world problems using MATLAB and/or SIMULINK.. `5 c2 u' }0 d7 N Practice Set C, Developing YourMATLABSkills , contains practice problems whose solutions use the methods and techniques you learned in Chapters 6–9. Chapter 10, MATLABand the Internet, gives tips on how to post MATLAB7 C; Q; `2 {) ] output on the Web.( F5 L0 C2 H5 I( h" \: ^( J Chapter 11, Troubleshooting, is the place to turn when anything goes wrong. Many common problems can be resolved by reading 0 n( q: M% ~+ H 3 |/ q: Y6 m) q# H 0 W& p5 x9 a# r; w l伶小  \0 Z% i/ p' Y ( l  v( u0 ~! Y7 n( p7 I& L. {6 T 6 Y9 i  h# W5 K/ e 联系QQ：526781618) h5 w. f4 g& X # n* @+ R8 F. V3 f) c: V 淘宝旺旺：跟朝流走. U) Z1 T, }' x3 s* f" z3 s 有需要的欢迎联系！专业代购电子书, n- u\$ G3 J% U8 N1 M8 Q( I 6 A+ p8 q. E: n4 m+ b   y6 ^, C1 y% ^\$ J# [: v . e9 R1 ?' `. p. K! n " J" y, W, A- r& [) j0 k ebook 英文电子书代购 % R" Y! K& J; A7 B; z4 f3 l: y. J