6

Conditional Statements in Matlab

Chapter Outline

Lesson 6.1 The Construction of an if Statement

Lesson 6.2 The Construction of an if else Statement

Lesson 6.3 Recursive Functions

Lesson 6.4 The Construction of an if elseif else Statement

Lesson 6.5 The Construction of a switch case Statement

Answers to Selected Exercises

## Lesson 6.1 The Construction of an if Statement

Objectives

• To learn how to exchange the values of two variables.

• To learn how to construct an if statement.

• To learn how to improve the readability of Matlab functions.

Topics

6.1.1 Swap the Values of Two Variables

6.1.2 if Statement

6.1.3 Improving the Readability of Matlab Functions

6.1.4 Examples for if Statements

### 6.1.1 Swap the Values of Two Variables

The figure ...