In this tutorial, we will learn about the Octave break Statement. We can use the break statement within the body of a loop.
Octave break statement
The break statement jumps the control out of the innermost loop that encloses the statement.
When Octave encounters the break statement, it breaks out of the loop. The statement that is immediately after the loop will be executed. We can use this statement in the loop to check special conditions and can skip the loop altogether.
% Break Statement Demo % Octave Tutorials - www.TestingDocs.com i = 0; while (true) disp(i); i++; if (i > 5) break; % Quit the loop if i > 5 endif endwhile
In the example, the break statement is used to quit the loop when the variable is greater than 5.
To skip the current iteration of the loop, we can use the continue statement.
Octave Tutorial on this website can be found at:
More information on Octave can be found on the official website: