美文网首页
Matlab中break和continue的区别

Matlab中break和continue的区别

作者: 安公子_ | 来源:发表于2017-07-01 12:26 被阅读0次

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并直接跳出循环。

相关文章

网友评论

      本文标题:Matlab中break和continue的区别

      本文链接:https://www.haomeiwen.com/subject/jzajxxtx.html