A Guide to MATLAB for Beginners and Experienced Users 2nd ed - B. Hunt, et al., (Cambridge, 2006) WW.pdf

(2380 KB) Pobierz
665882891 UNPDF
A Guide to M ATLAB ®
for Beginners and Experienced Users
Second Edition
Updated for M ATLAB ® 7 and Simulink ® 6
Brian R. Hunt
Ronald L. Lipsman
Jonathan M. Rosenberg
All of the University of Maryland, College Park
with
Kevin R. Coombes
John E. Osborn
Garrett J. Stuck
665882891.001.png
cambridge university press
Cambridge, New York, Melbourne, Madrid, Cape Town, Singapore, São Paulo
Cambridge University Press
The Edinburgh Building, Cambridge
cb2 2ru
,UK
Published in the United States of America by Cambridge University Press, New York
www.cambridge.org
© B.Hunt, R.Lipsman, J.Rosenberg, K.Coombes, J. Osborn, and G.Stuck 2001, 2006
This publication is in copyright. Subject to statutory exception and to the provision of
relevant collective licensing agreements, no reproduction of any part may take place
without the written permission of Cambridge University Press.
First published in print format
2006
isbn-13 978-0-511-21985-6
eBook (EBL)
eBook (EBL)
isbn-10 0-511-21985-7
isbn-13 978-0-521-85068-1
hardback
isbn-10 0-521-85068-1
hardback
isbn-13 978-0-521-61565-5
paperback
paperback
isbn-10 0-521-61565-8
s
for external or third-party internet websites referred to in this publication, and does not
guarantee that any content on such websites is, or will remain, accurate or appropriate.
url
Cambridge University Press has no responsibility for the persistence or accuracy of
665882891.002.png
Contents
The symbol denotes a more advanced chapter or section.
Preface
page xi
Why We Wrote This Book
xi
Who Should Read This Book
xii
How This Book Is Organized
xii
Conventions Used in This Book
xiv
About the Authors
xv
1 Getting Started
1
Platforms and Versions
1
Installation
2
Starting MATLAB
2
Typing in the Command Window
3
Online Help
3
MATLAB Windows
6
Ending a Session
6
2 MATLAB Basics
7
Input and Output
7
Arithmetic
8
Recovering from Problems
9
Errors in Input
9
Aborting Calculations
9
Algebraic or Symbolic Computation
10
Substituting in Symbolic Expressions
10
Symbolic Expressions, Variable Precision, and Exact Arith-
metic
11
Vectors and Matrices
12
Vectors
13
Matrices
14
Suppressing Output
15
Functions
15
Built-in Functions
15
User-Defined Functions
16
Managing Variables
17
v
vi
Contents
Variables and Assignments
18
Solving Equations
20
Graphics
22
Graphing with ezplot
22
Modifying Graphs
23
Graphing with plot
24
Plotting Multiple Curves
25
3 Interacting with MATLAB
27
The MATLAB Interface
27
The Desktop
27
The Workspace
28
The Current Directory and Search Path
28
The Command History Window
30
M-Files
31
Script M-Files
31
Function M-Files
33
Loops
35
Presenting Your Results
35
Publishing an M-File
36
Diary Files
37
Interactive M-Files
37
Wrapping Long Input and Output Lines
38
Printing and Saving Graphics
38
M-Books
39
Fine-Tuning Your M-Files
41
Practice Set A: Algebra and Arithmetic
43
4 Beyond the Basics
45
Suppressing Output
45
Data Classes
46
String Manipulation
47
Symbolic and Floating-Point Numbers
48
Functions and Expressions
48
Substitution
50
More about M-Files
50
Variables in Script M-Files
50
Variables in Function M-Files
50
Structure of Function M-Files
51
Complex Arithmetic
51
More on Matrices
52
Solving Linear Systems
53
Calculating Eigenvalues and Eigenvectors
53
Doing Calculus with MATLAB
54
Contents
vii
Differentiation
54
Integration
54
Limits
55
Sums and Products
56
Taylor Series
57
Default Variables
57
5 MATLAB Graphics
59
Two-Dimensional Plots
59
Parametric Plots
59
Contour Plots and Implicit Plots
60
Field Plots
62
Three-Dimensional Plots
62
Curves in Three-Dimensional Space
62
Surfaces in Three-Dimensional Space
64
Figure Windows
65
Multiple Figure Windows
66
The Figure Toolbar
66
Combining Plots in One Window
67
Customizing Graphics
67
Annotation
69
Change of Plot Style
70
Full-Fledged Customization
71
Images, Animations, and Sound
73
Images
74
Animations
76
Sound
77
Practice Set B: Calculus, Graphics, and Linear Algebra
79
6 MATLAB Programming
85
Branching
85
Branching with if
85
Logical Expressions
87
Branching with switch
91
More about Loops
92
Open-Ended Loops
92
Breaking from a Loop
93
Other Programming Commands
94
Subfunctions
94
Cell and Structure Arrays
94
Commands for Parsing Input and Output
95
Evaluation and Function Handles
97
User Input and Screen Output
98
Debugging
100
Zgłoś jeśli naruszono regulamin