English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The continue statement is used to pass control to the next iteration of a for or while loop.
The way MATLAB works with the continue statement is similar to the break statement. However, 'continue' does not force termination, but forces the next iteration of the loop to occur, skipping any intermediate code.
Create a script file and enter the following code-
a = 9; % While loop execution while a < 20 a = a + 1; if a == 15 % skip the iteration continue; end fprintf('value of a: %d\n', a); endWhen running the file, it displays the following result-
value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 16 value of a: 17 value of a: 18 value of a: 19 value of a: 20