Octave while Statement
Octave while Statement
In this tutorial, we will learn about Octave while statement. The while statement is a loop statement in Octave.
while Statement Syntax
The general Octave’s while statement syntax is as follows:
while (condition)
  body
endwhile
or
while (condition)
  body
end
The while statement executes the loop statements as long as the while condition is true. The condition expression in the while statement is considered true if its value is non-zero, and false if its value is zero.
The while is an indefinite loop. We can use this loop when we don’t know beforehand the number of iterations for the loop. The loop executes until the loop condition is true.
Example
% Sample Octave Script
% while Loop Demo
% Octave Tutorials – www.TestingDocs.com
% Initialize loop variable
loopVar = 1;
% While Loop to print 1 – 10
while( loopVar <= 10)
    disp(loopVar);
    loopVar++;
endwhile
Screenshot
Octave Tutorials
Octave Tutorial on this website can be found at:
More information on Octave can be found on the official website: