Chapter 9. Errors and Pitfalls

Even experienced programmers seldom have programs run correctly the first time. In computer jargon, an error in a program is a bug. The story is that a hapless moth short-circuited two thermionic valves in one of the earliest computers. This primeval (charcoaled) “bug” took days to find. The process of detecting and correcting errors is therefore called debugging.

There are many types of errors and pitfalls, some that are peculiar to MATLAB and some that may occur when programming in any language. These are discussed briefly in this chapter.

Syntax Errors

Syntax errors are typing mistakes in MATLAB statements (e.g., plog ...

Get Essential MATLAB for Engineers and Scientists Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.