Buy this book at Amazon.com
This HTML version of the book is provided as a convenience, but some math equations are not translated correctly. The PDF version is more reliable.
Chapter 1 Preface
Most books that use MATLAB are aimed at readers who know how
to program. This book is for people who have never programmed
As a result, the order of presentation is unusual. The book starts
with scalar values and works up to vectors and matrices very
gradually. This approach is good for beginning programmers, because
it is hard to understand composite objects until you understand basic
programming semantics. But there are problems:
- The MATLAB documentation is written in terms of matrices,
and so are the error messages.
To mitigate this problem, the book explains the necessary
vocabulary early and deciphers some of the messages that
beginners find confusing.
- Many of the examples in the first half of the book are
not idiomatic MATLAB code. I address this problem in the second
half by translating the examples into a more standard style.
The book puts a lot of emphasis on functions, in part because they are
an important mechanism for controlling program complexity, and also
because they are useful for working with MATLAB tools like fzero
I assume that readers know calculus, differential equations, and
physics, but not linear algebra. I explain the math as I go along,
but the descriptions might not be enough for someone who hasn’t seen
the material before.
There are small exercises within each chapter, and a few larger
exercises at the end of some chapters.
If you have suggestions and corrections, please send them to
Allen B. Downey
The following are some of the people who have contributed to this
- Michael Lintz spotted the first (of many) typos.
- Kaelyn Stadtmueller reminded me of the importance of linking
- Roydan Ongie knows a matrix when he sees one (and caught a typo).
- Keerthik Omanakuttan knows that acceleration is not the
second derivative of acceleration.
- Pietro Peterlongo pointed out that Binet’s formula is an
exact expression for the nth Fibonacci number, not an approximation.
- Li Tao pointed out several errors.
- Steven Zhang pointed out an error and a point of confusion
in Chapter 11.
- Elena Oleynikova pointed out the “gotcha” that script file names
can’t have spaces.
- Kelsey Breseman pointed out that numbers as footnote markers
can be confused with exponents, so now I am using symbols.
- Philip Loh sent me some updates for recent revisions of MATLAB.
- Harold Jaffe spotted a typo.
- Vidie Pong pointed out the problem with spaces in filenames.
- Nik Martelaro suggested using the mcode package to make the
code examples look better.
- Arjun Plakkat found a numerical error.
- Craig Scratchley led a project to produce a significantly
revised version of this book, with the help of SFU students Zhen, Zavier,
Michael, and Matt (as below).
- Zhen Gang Xiao synchronized MATLAB output with R2016b.
- Zavier Patrick Aguila consistently numbered equations.
- Michael Cline put in support for PDF bookmarks.
- Matt Wiens revised several sections of the book.
Are you using one of our books in a class?We'd like to know about it. Please consider filling out this short survey.
Think Python 2e
Think Stats 2e