


If ( condition) then-body else else-body endif The second form of an if statement looks like this: Matrix, it is considered true only if all of the elements are If the value of theĬonditional expression in an if statement is a vector or a Is non-zero, and false if its value is zero. The condition in an if statement is considered true if its value In its simplest form,Ĭondition is an expression that controls what the rest of the ThereĪre three basic forms of an if statement. The if statement is Octave's decision-making statement. While and the corresponding end statement is called the The list of statements contained between keywords like if or Preferred because if you use them, Octave is able to provide betterĭiagnostics for mismatched or missing end tokens. You can use the keyword end anywhere a more specificĮnd keyword is expected, but using the more specific keywords is Statement, and endwhile marks the end of a while ForĮxample, the keyword endif marks the end of an if Statement that marks the end of the end of the control statement. Each control statement has a corresponding end If statement contains another statement which may or may not beĮxecuted. Many control statements contain other statements for example, the While, to distinguish them from simple expressions. Statements start with special keywords such as if and Go to the first, previous, next, last section, table of contents.Ĭontrol statements such as if, while, and so onĬontrol the flow of execution in Octave programs.
