
continue语句用于将控制传递给for或while循环的下一个迭代。
MATLAB中的continue语句的工作方式与break语句类似。然而,“continue”不是强制终止,而是强制循环的下一次迭代发生,跳过中间的任何代码。
流程图

在线示例
创建一个脚本文件并输入以下代码-
a = 9;
%While 循环执行
while a < 20
a = a + 1;
if a == 15
% skip the iteration
continue;
end
fprintf('value of a: %d\n', a);
end运行文件时,它显示以下结果-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