The scope of the for statement is always terminated with a matching end. Without an end statement, for, while, and if wait for further input. Each end is paired with the closest previous unpaired for, while, or if. The end command can also serve as the last index in an indexing expression. This example shows end used with for and if.
Indentation provides easier readability.
Each if must be paired with a matching end. See Examples for information about how nonscalar variables are evaluated. Expressions are evaluated as false unless every element-wise comparison evaluates as true . Conditionally execute statements Syntax if expression statements else statements end Description The else command is used to delineate an alternate block of statements. The second set of statements is executed if the expression has any zero elements.