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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.