Matlab中break和continue的区别

continue:
用于与跳过循环中的语句,进行下一次循环;例如:

for i = 1:len
  ...porgram body 1
  if condition
    ...porgram body 2
    continue;
    ...porgram body 3
  end
  ...porgram body 4
end

满足条件后,跳过porgram body 3porgram body 4直接进入下一次循环。

break:
用于与跳出循环语句,例如:

for i = 1:len
  ...porgram body 1
  if condition
    ...porgram body 2
    continue;
    ...porgram body 3
  end
  ...porgram body 4
end

满足条件后,跳过porgram body 3porgram body 4并直接跳出循环。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容