MATLAB if... end Statement MATLAB

What is MATLAB if... end Statement?

An if ... end statement consists of an if statement and a boolean expression followed by one or more statements. It is delimited by the end statement.

Syntax

The syntax of an if statement in MATLAB is –

If the expression evaluates to proper, then the block of code inside the if statement will be completed. If the expression evaluates to false, then the first set of code after the end statement will be done.

Flow Diagram

MATLAB - if... end Statement

Example

Create a script file and type the following code –

When you run the file, it displays the following result –

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

MATLAB Topics