Preface
Acknowledgments
1 Introduction
Differentiation and integration
3 Program Design and Algorithm Development
3.1 The program design process
3.1.1 The projectile problem
3.2 Programming MATLAB functions
3.2.1 Inline objects: Harmonic oscillators
3.2.2 MATLAB function: y = fx
Summary
Exercise
4 MATLAB Functions and Data Import-Export Utilities
4.1 Common functions
4.2 Importing and exporting data
4.2.1 The load and save commands
4.2.2 Exporting text ASCII data
4.2.3 Importing text ASCII data
4.2.4 Exporting binary data
4.2.5 Importing binary data
Summary
Exercises
5 Logical Vectors
5.1 Examples
5.1.1 Discontinuous graphs
5.1.2 Avoiding division by zero
5.1.3 Avoiding in?nity
5.1.4 Counting random numbers
5.1.5 Rolling dice
5.2 Logical operators
5.2.1 Operator precedence
5.2.2 Danger
5.2.3 Logical operators and vectors
5.3 Subscripting with logical vectors
5.4 Logical functions
5.4.1 Using any and all
5.5 Logical vectors instead of elseif ladders
Summary
Exercises
Appendix 5.A Supplementary material
6 Matrices and Arrays
7 Function M-?les
7.1 Example: Newton's method again
7.2 Basic rules
7.2.1 Subfunctions
7.2.2 Private functions
7.2.3 P-code ?les
7.2.4 Improving M-?le performance with the pro?ler
7.3 Function handles
7.4 Command/function duality
7.5 Function name resolution
7.6 Debugging M-?les
7.6.1 Debugging a script
7.6.2 Debugging a function
7.7 Recursion
Summary
Exercises
Appendix 7.A Supplementary material
8 Loops
8.1 Determinate repetition with for
8.1.1 Binomial coef?cient
8.1.2 Update processes
8.1.3 Nested fors
8.2 Indeterminate repetition with while
8.2.1 A guessing game
8.2.2 The while statement
8.2.3 Doubling time of an investment
8.2.4 Prime numbers
8.2.5 Projectile trajectory
8.2.6 break and continue
8.2.7 Menus
Summary
Exercises
10 Vectors as Arrays and Other Data Structures
10.1 Update processes
10.1.1 Unit time steps
10.1.2 Non-unit time steps
10.1.3 Using a function
10.2 Frequencies, bar charts and histograms
10.2.1 A random walk
10.2.2 Histograms
10.3 Sorting
10.3.1 Bubble Sort
10.3.2 MATLAB's sort
10.4 Structures
10.5 Cell arrays
10.5.1 Assigning data to cell arrays
10.5.2 Accessing data in cell arrays
10.5.3 Using cell arrays
10.5.4 Displaying and visualizing cell arrays
10.6 Classes and objects
Summary
11 Errors and Pitfalls
11.1 Syntax errors
11.1.1 Incompatible vector sizes
11.1.2 Name hiding
11.2 Logic errors
11.3 Rounding error
Summary
Chapter exercises
12 Dynamical Systems
12.1 Cantilever beam
12.2 Electric current
12.3 Free fall
12.4 Projectile with friction
Summary
Exercises
13 Simulation
13.1 Random number generation
13.1.1 Seeding rand
13.2 Spinning coins
13.3 Rolling dice
13.4 Bacteria division
13.5 A random walk
13.6 Traf?c ?ow
13.7 Normal Gaussian random numbers
Summary
Exercises
15 Signal Processing
15.1 Harmonic analysis
15.2 Fast Fourier Transform FFT
16 SIMULINK"572 Toolbox
16.1 Mass-spring-damper dynamic system
16.2 Bouncing ball dynamic system
16.3 The van der Pol oscillator
16.4 The Duf?ng oscillator
Exercises
Appendix 16.A Supplementary material
17 Symbolics Toolbox
17.1 Algebra
17.1.1 Polynomials
17.1.2 Vectors
17.1.3 Matrices
17.2 Calculus
17.3 Laplace and Z transforms
17.4 Generalized functions
17.5 Differential equations
17.6 Implementation of funtool, MuPAD and help
17.6.1 The funtool
17.6.2 The MuPAD notebook* and Symbolic help
Exercises
A.1 Expressions
A.2 Function M-?les
A.3 Graphics
A.4 if and switch
A.5 for and while
A.6 Input/output
A.7 load/save
A.8 Vectors and matrices
C.1 General-purpose commands
C.1.1 Managing variables and the workspace
C.1.2 Files and the operating system
C.1.3 Controlling the Command Window
C.1.4 Starting and quitting MATLAB
C.2 Logical functions
C.3 MATLAB programming tools
C.3.1 Interactive input
C.4 Matrices
C.4.1 Special variables and constants
C.4.2 Time and date
C.4.3 Matrix manipulation
C.4.4 Specialized matrices
C.5 Mathematical functions
C.6 Matrix functions
C.7 Data analysis
C.8 Polynomial functions
C.9 Function functions
C.10 Sparse matrix functions
C.11 Character string functions
C.12 File I/O functions
C.13 2D graphics
C.14 3D graphics
C.15 General
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 11
Chapter 13
Chapter 14