MATLAB if-else... end statement

If the first condition is not true, then we can define other statements to run by using the else keyword.

Syntax:

Flow Diagram of if...else...end Statement

MATLAB if-else... end statement

Example1:

Output:

a = 15
an odd number

Example2:

Using if-else statement to determine the largest of two number

Output:

Enter number 1: 15
Enter number 2:20
num1 is less than num2





Contact US

Email:[email protected]

if-else... end statement
10/30