Summary

Summary Now that you have finished this chapter, you should be able to write programs that can perform decision-making procedures; that is, the program’s operations depend on results of the program’s calculations or on input from the user. Sections...

The switch Structure

The switch Structure The switch structure provides an alternative to using the if, elseif, and else commands. Anything programmed using switch can also be programmed using it structures. However, for some applications the switch structure is more readable than code...

Debugging MATLAB Programs

Debugging MATLAB Programs Use of the MATLAB Editor/Debugger as an M-file editor was discussed in Section 1.4 of Chapter 1. Figure 1.4-1 (in Chapter 1) shows the Editor/Debugger screen. Figure 4.7-1 shows the Debugger containing two programs to be analyzed. Here we...

Conditional Statements

Conditional Statements In everyday language we describe our decision making by using conditional phrases such as.If I get a raise, I will buy a new car. If the statement, I get a raise, is true, the action indicated (buy a new car) will be executed. Here is...

Relational Operators and Logical Variables

Relational Operators and Logical Variables MATLAB has six relational operators to make comparisons between arrays. These operators are shown in Table 4.2-1 and were introduced in Section 1.3. Recall that the equal to operator consists of two = signs, not a single =...

Logical Operators and Functions

Logical Operators and Functions MATLAB has five logical operators, which are sometimes called Boolean operators (see Table 4.3-1). These operators perform element-by-element operations. With the exception of the NOT operator (-), they have a lower precedence than the...