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

 Contents at a Glance Preface page xiii+ r5 \6 j2 I" [* H 1 Getting Started 13 u3 F* s0 N( n: F; p 2 MATLAB Basics 8 3 Interacting with MATLAB 313 Y( v& ~% A  h+ V6 k+ p Practice Set A: Algebra and Arithmetic 48 4 Beyond the Basics 50 5 MATLAB Graphics 679 F; J1 @/ d9 ?6 X" @. `. I/ ] Practice Set B: Calculus, Graphics, and Linear Algebra 86 6 M-Books 91) u+ G+ ?' ~5 c* w' T6 T9 n 7 MATLAB Programming 1013 M2 y/ [' @: q. | 8 SIMULINK and GUIs 121' I! x, y- [% ~: }2 Q 9 Applications 136* |  b\$ t  k+ J  t( H Practice Set C: Developing Your MATLAB Skills 204% \6 z3 i- h8 X. ]0 i/ l7 m# _1 l 10 MATLAB and the Internet 214 11 Troubleshooting 2183 t* _, C7 ^! Y% t8 D# \ Solutions to the Practice Sets 235 Glossary 2996 s0 l9 j2 L8 t\$ ^7 R% d\$ l Index 317  U. k8 k* i" X  ] v4 F6 U  H5 U6 T8 X, O4 [8 @% l 3 y& C# e% q" D, I Contents Preface page xiii 1 Getting Started 12 b+ ?2 h- U' p1 u Platforms and Versions 1 Installation and Location 2 Starting MATLAB 2 Typing in the Command Window 3. i+ H4 y% U% v# Q( i  d7 y5 C Online Help 4; t0 N2 \: q9 ?\$ H6 p2 W8 K" E Interrupting Calculations 5 MATLAB Windows 6, L# x7 M6 u: y- W5 z6 E7 n: P) l Ending a Session 7% Z2 J% O2 {" z; K' ~( L+ S. L; z 2 MATLAB Basics 8% T- _! F7 y6 ~ Input and Output 8* g4 i9 u9 U, @2 Z% d0 P\$ V6 S* \; S/ K Arithmetic 8 Algebra 100 f+ k0 [" _. q0 a* d9 Z; g0 W( y Symbolic Expressions, Variable Precision, and Exact! _) ~8 ]2 t7 w8 e Arithmetic 11 Managing Variables 13 Errors in Input 14 Online Help 15 Variables and Assignments 16) ^" l( g7 U% j" m  [* ? Solving Equations 17 Vectors and Matrices 201 @! |6 U2 e, k5 h6 F# X/ p Vectors 21! P; x9 h6 N. r9 L8 T6 {4 P Matrices 23! s! ~; ?4 A\$ o5 ~& w Suppressing Output 24" m# V' J( C4 K: ?6 R- x Functions 24/ n& U& W8 o+ f. ~3 i vii viii Contents Built-in Functions 24- {" z: A  D/ v7 o/ W User-Defined Functions 25( }" v2 X, A, V! B1 `  p Graphics 26. F; j- h% S% S5 n6 }9 L Graphing with ezplot 26. _9 h( J0 L5 ?  r; b; b4 y. T Modifying Graphs 27: _" F6 r+ |7 L. e6 S1 U Graphing with plot 288 Y& X% ^; ^, n Plotting Multiple Curves 301 t) x% `. `( A6 r 3 Interacting with MATLAB 311 R' u; H, s0 y' p8 ~) M( e The MATLAB Interface 31 The Desktop 31* i, a# u6 j8 \: m# k" D- O Menu and Tool Bars 33 The Workspace 33 The Working Directory 349 c+ |( M  q. L0 l9 q9 z) H1 | Using the Command Window 35 M-Files 36 Script M-Files 37 Function M-Files 39  `) f# n. k. [! O& U) x Loops 41. ~9 b) P* Z' U/ W1 T! Q8 Y Presenting Your Results 41, w8 d: T5 F: X1 B\$ @2 S1 H! m) K Diary Files 42 Presenting Graphics 43 Pretty Printing 45 A General Procedure 45' }9 r8 x4 Y. L- D7 d Fine-Tuning Your M-Files 46 Practice Set A: Algebra and Arithmetic 48: p\$ ~2 l; @9 a! p 4 Beyond the Basics 50 Suppressing Output 50# M* e% M) |6 b\$ F; { Data Classes 51 String Manipulation 53 Symbolic and Floating Point Numbers 53 Functions and Expressions 54 Substitution 56* y. Z& L( k5 y: a+ J) |, i8 x2 y( ~8 G More about M-Files 56 Variables in Script M-Files 56 Variables in Function M-Files 572 s3 Z2 b# Z# Y" w( j; ~( ] Structure of Function M-Files 57& g; ~  _6 A: b( ?% i! ]% V( Y Contents ix% C' @) M' j\$ W7 f% e1 v Complex Arithmetic 58 More on Matrices 59 Solving Linear Systems 60 Calculating Eigenvalues and Eigenvectors 60! d6 e/ |1 k1 Q' S9 y; q8 ]* E. v Doing Calculus withMA TLAB 61 Differentiation 61 Integration 626 p, q3 y* U4 I7 J Limits 63\$ U1 l4 o, v1 v4 b Sums and Products 64& D* E% f* a0 j1 O5 k9 t Taylor Series 65" j: g  E; i/ f  R9 Z1 H Default Variables 65 5 MATLAB Graphics 67 Two-Dimensional Plots 67 Parametric Plots 67 Contour Plots and Implicit Plots 698 e! g4 b) G0 E8 L1 m Field Plots 71- V4 E- i  e& e: Z5 r! r Three-Dimensional Plots 726 A( W( T; e8 u9 `" M Curves in Three-Dimensional Space 72+ z2 G! _. h4 ?) y Surfaces in Three-Dimensional Space 73* @! E0 o4 {- h Special Effects 75% S3 C- m! ?' m( g* p+ \% F Combining Figures in One Window 765 I5 y4 U& ^; ?, w+ V2 o& Y" T Animations 77 Customizing and Manipulating Graphics 78; g; C4 w5 w* z Change of Viewpoint 80 Change of Plot Style 80! y8 k% n0 K1 [& J" F# F% F Full-Fledged Customization 823 [2 o# L7 w, h Quick Plot Editing in the Figure Window 84 Sound 85 Practice Set B: Calculus, Graphics, and Linear Algebra 86 6 M-Books 91 Enabling M-Books 92 Starting M-Books 93 Working withM-Books 952 L7 m+ G+ N9 i; p  d Editing Input 95, h0 C& {4 G4 U/ z( k1 _+ o\$ o) L, ` The Notebook Menu 96 x Contents M-Book Graphics 97 More Hints for Effective Use of M-Books 98/ e\$ S& k: u( V- k/ b A Warning 994 L8 c\$ }! X! l; K( K) Q1 ` 7 MATLAB Programming 101  d: G6 a% c# y8 l; A- ^6 E8 ~ Branching 101' W% U: G2 v& f7 x- Z Branching with if 102; g' ^1 D" g5 {6 W7 W( L Logical Expressions 1049 P+ R( ~- t/ {9 M; l Branching with switch 108 More about Loops 109 Open-Ended Loops 110- m9 c3 c6 M7 O& y9 E Breaking from a Loop 1116 L\$ L7 `/ w( T. f; O8 W Other Programming Commands 112 Subfunctions 1120 n7 S, d2 p3 } Commands for Parsing Input and Output 112 User Input and Screen Output 114 Evaluation 116% t) Q0 t- e% c% G* q. Z9 E Debugging 1177 Q. d\$ n' @: y% c1 |2 R) o/ h6 w Interacting withth e Operating System 118( _) q! s6 q: G. D+ H( _, o\$ D\$ B0 { Calling External Programs 118 File Input and Output 119* Y/ e% L: U) z- m7 t8 i+ f: G 8 SIMULINK and GUIs 121) ~% M& |) ?9 H0 U- p SIMULINK 121( E& v2 f+ _  ^0 h9 b Graphical User Interfaces (GUIs) 127 GUI Layout and GUIDE 127: ]( L3 |( d# a1 d; ` Saving and Running a GUI 130 GUI Callback Functions 132 9 Applications 136 Illuminating a Room 1376 n: z9 ~- q/ D7 X6 E4 e  t One 300-Watt Bulb 137! w" o6 W+ `0 P Two 150-Watt Bulbs 138# H9 z" H' u" ]  I* _8 R, I, q Three 100-Watt Bulbs 143( `( h7 E& x; k2 f Mortgage Payments 1458 L% S% O# t3 V, i' L: L, Q: N Monte Carlo Simulation 149 Population Dynamics 156 Exponential Growthand Decay 157 Contents xi( A& S& ^7 B5 Z1 k% p6 { LogisticGrowth159 Rerunning the Model with SIMULINK 166 Linear Economic Models 168 Linear Programming 173 The 360? Pendulum 180& g' M! Q) f& w; l Numerical Solution of the Heat Equation 184& U* P* T: S6 F% _8 A8 s\$ y1 F A Finite Difference Solution 185 The Case of Variable Conductivity 1892 Z& {& J; h\$ j A SIMULINK Solution 191, r+ X  h4 M\$ `7 W Solution with pdepe 194 A Model of Traffic Flow 196 Practice Set C: Developing Your MATLAB Skills 204, d\$ e/ \2 x; v# N. W5 G 10 MATLAB and the Internet 214- A' s\$ S2 Z2 } MATLAB Help on the Internet 214 Posting MATLAB Programs and Output 215 M-Files, M-Books, Reports, and HTML Files 215 Configuring Your Web Browser 216 Microsoft Internet Explorer 216 Netscape Navigator 216 11 Troubleshooting 2185 U' K% e6 h; l  B# b Common Problems 218+ O6 W# {. r; V' V" h7 K\$ ~ Wrong or Unexpected Output 2181 y+ ]- n7 g- P. F Syntax Error 220 Spelling Error 223 Error Messages When Plotting 223 A Previously Saved M-File Evaluates Differently 224 Computer Won’t Respond 2261 Z3 G+ \& r1 O3 W; C The Most Common Mistakes 226 Debugging Techniques 227 Solutions to the Practice Sets 2355 n4 n/ x4 E6 _6 C" X, ? Practice Set A 235. N  ?& T1 r. i7 K+ h Practice Set B 246' \& z) K! w. j1 ?* b( b Practice Set C 266 xii Contents; v% Z* R3 A: O& A6 Y' t/ [- b\$ Y Glossary 2995 `: h- u- W9 l MATLAB Operators 300 Built-in Constants 301& u7 _( {( x7 C7 ?( ~+ U* g Built-in Functions 302( s3 N\$ V. ?  F% |6 Y7 {: k# i% L MATLAB Commands 303 Graphics Commands 309/ F+ a) U1 |0 D% a MATLAB Programming 313, e9 o9 O% d4 S* ?7 ?7 v+ ~ Index 317 indicates an advanced chapter or section that can be skipped on a first reading.6 f0 D+ o" N\$ }# Z9 a Preface! i9 F( E\$ T2 O\$ A4 S& W- v/ [ That statement encapsulates the view of The MathWorks, Inc., the developer of MATLAB . MATLAB 6 is an ambitious program. It contains hundreds of commands* b0 d8 J\$ r+ O% p' A- V to do mathematics. You can use it to graph functions, solve equations, perform statistical tests, and do much more. It is a high-level programming; {& X0 A, R6 y/ c  {' w4 I' w% Y language that can communicate with its cousins, e.g., FORTRAN and C. You/ T0 O\$ R& P/ J 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 its' N7 L% v% J, k accessory SIMULINK ). You can prepare materials for export to the World" e; n! r1 Y+ J- U Wide Web. In addition, you can use MATLAB, in conjunction withth e word, T' l# J4 T' @) [% m processing and desktop publishing features of Microsoft Word , to combine1 D! S* }0 V1 s( y; X8 ^8 R mathematical computations with text and graphics to produce a polished, integrated, and interactive document. A program this sophisticated contains many features and options. There\$ g) X5 v6 g" p9 z( [7 G are literally hundreds of useful commands at your disposal. The MATLAB" s. g6 i0 L7 Z( W- R5 t/ z, y help documentation contains thousands of entries. The standard references,\$ m# |0 I! k- j' q2 v0 d9 Z* J' s& L6 t whether the MathWorks User’s Guide for the product, or any of our competitors,; _# F3 f. J( A5 v2 Q; p5 B  ^ contain myriad tables describing an endless stream of commands,9 j4 D" a& C1 ]3 H! ^% N! f options, and features that the user might be expected to learn or access. MATLAB is more than a fancy calculator; it is an extremely useful and" Y6 [+ {1 ]! |) q versatile tool. Even if you only know a little about MATLAB, you can use it 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.! w7 M. ~( |: ]+ c( C That’s where we come in.7 o4 x" J- \" j9 _) |0 [ xiii xiv Preface' S; o( T2 W\$ n' F* M/ M( q3 b Why We Wrote This Book; f\$ P2 J; q  K\$ o% x+ [' f+ d& e, { The goal of this book is to get you started using MATLAB successfully and8 n3 ~- Y/ D  o8 J  Y: _8 w quickly. We point out the parts of MATLAB you need to know without overwhelming% I4 M, u7 x4 t& x7 v" t+ L) G' ~ you with details. We help you avoid the rough spots. We give you examples of real uses of MATLAB that you can refer to when you’re doing- A( m1 E8 ]2 p8 H4 { 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 your9 _( K. b6 X: l! d( a4 w+ ^6 n own. You might not be a MATLAB expert when you finish this book, but you 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! [0 ]* ]* e; i that’s finance, physics, psychology, or engineering. You want to use MATLAB the way we do, as a tool. This book is designed to help you become a proficient MATLAB user as quickly as possible, so you can get on withth e business at hand. Who Should Read This Book" L, V0 O7 V, h8 L 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" d* `  q9 L) `/ n 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 with2 c! S) x, r1 V7 O\$ [) n. w; O MATLAB and told you to learn how to use it, then you’ll find the book particularly3 l% e2 A) i5 x useful. If you are teaching or taking a course in which you want to# O, `\$ k- c: p( ]' [ 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.+ v\$ U\$ q\$ F4 |+ J( S8 ~# J1 A Virtually all of the material on MATLAB commands in this book applies to4 o5 f  n& N3 g8 o" v 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 xv8 L8 h; `\$ [0 T( ?/ s9 k1 g& y 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, [  Y( m/ A4 U4 f+ b3 f MATLAB. It contains practice problems (withcomplete solutions) so you can test your knowledge. There are several illuminating sample projects that show2 B5 ~9 t4 s, l8 x7 x) E you how MATLAB can be used in real-world applications, and there is an entire  N& e8 B3 Q, ~8 G9 Y: O chapter on troubleshooting.5 v6 d3 T  h( z8 y. \% H/ n2 M 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 —% [1 ?% S. c3 C- {; ^3 A2 ]3 A 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 different+ U! ^5 {" U: D( w) X8 h 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  U2 v\$ o' X4 Q; k exit the application.( A7 n( `. ]+ c0 `5 J+ K Chapter 2, MATLABB asics, shows you how to do elementary mathematics( T8 j# K) q5 }  U* J using MATLAB. This chapter contains the most essential MATLAB0 E0 c- W+ y8 u4 }7 s& B commands.1 U  m" N! a4 a- L5 P 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 you will use to make most effective use of the software, and to a simple method/ e8 {. L6 X* F/ o, O (diary files) of documenting your MATLAB sessions. After completing this4 X4 [# }" l2 |  s9 `% A  K( ` chapter, you’ll have a better appreciation of the breadth described in the quote that opens this preface. Practice Set A, Algebra and Arithmetic, contains some simple problems for practicing your newly acquired MATLAB skills. Solutions are presented at' V- j' p% N; p) k- J# P! B the end of the book. Chapter 4, Beyond the Basics, contains an explanation of the finer points that are essential for using MATLAB effectively.) T% A& h2 ^+ P/ _ Chapter 5, MATLABGraphics , contains a more detailed look at many of' @4 l# H+ L3 E; X9 z4 |  @ the MATLAB commands for producing graphics. Practice Set B, Calculus, Graphics, and Linear Algebra, gives you another, c4 R, }/ c9 ]' b' l chance to practice what you’ve just learned. As before, solutions are provided/ R5 `\$ R3 c6 U& u  e at the end of the book.( b  k0 \( {# Y: J\$ J xvi Preface\$ h# `- X9 ]! `& x Chapter 6, M-Books, contains an introduction to the word processing and desktop publishing features available when you combine MATLAB with Microsoft Word. Chapter 7, MATLABProgramming , introduces you to the programming, o! h8 r4 |: h3 j features of MATLAB. This chapter is designed to be useful both to the novice programmer and to the experienced FORTRAN or C programmer." i' _3 V6 p\$ ^ Chapter 8, SIMULINK and GUIs, consists of two parts. The first part describes9 F: C3 l- n5 @- ]: E the MATLAB companion software SIMULINK, a graphically oriented* b' g& a7 p7 U0 M  a package for modeling, simulating, and analyzing dynamical systems. Many( k! s0 w( g! X of the calculations that can be done with MATLAB can be done equally well' R. \& J2 I1 U, D+ ~  D/ V with SIMULINK. If you don’t have access to SIMULINK, skip this part of) O3 Y2 c% A5 t" |, O% w' R( Y Chapter 8. The second part contains an introduction to the construction and deployment of graphical user interfaces, that is, GUIs, using MATLAB.2 z& F7 J; i2 }# ^& q\$ e7 U Chapter 9, Applications, contains examples, from many different fields, of; v4 M+ l" [( L* K  }# \2 M solutions of real-world problems using MATLAB and/or SIMULINK.9 l/ q6 A; f) N\$ [, ^2 u 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 MATLAB4 K+ W5 Z! J+ V( ?* Q) b, | output on the Web./ u! Q4 w* j2 E3 P Chapter 11, Troubleshooting, is the place to turn when anything goes wrong. Many common problems can be resolved by reading' ^, s, ~" a  s0 ], q. Z4 | 3 k' r6 x- ]7 I" n& h, h 9 s: D* t- k1 `9 q+ H) T\$ e, E l伶小 4 {, X3 A\$ W9 J; C6 b* t 8 G! r* |7 E0 y+ o   i5 H& o: g; M# W0 w 联系QQ：526781618+ ~# i3 w4 ~5 C5 N- Y- B  N0 |' C # k) a! z3 x& g4 v! h" |, W 淘宝旺旺：跟朝流走( d+ Q3 j\$ D# Q- H4 v\$ s9 n 有需要的欢迎联系！专业代购电子书6 M" {9 S6 p5 j0 k, a: t" u 8 O  o5 o, ^4 n5 ]\$ X   ]% j" V\$ q/ g * X: V9 }8 l5 @  p8 X' o ebook 英文电子书代购