Matlab break error

A BREAK may only be used within a FOR or WHILE loop, and then only within the same file as its corresponding FOR or WHILE statement
  • 很多老版本可以用,但是其他版本替换为return
R2015a/R2018a/R2020b:
break is not defined outside a for or while loop. To exit a function, use return.
ML7.1 (R14SP3, released September 2005)/R2010a/R2011a:
break is not defined outside a for or while loop. Use return in this context instead.
That sounds more like it is discouraging, implying with the word 'instead' that this is a change. Let's look back a little further.
ML6.5 (R13, released July 2002):
break is not defined outside of a for or while loop. Use return in this context instead.
OK, so the word 'of' was removed in later releases. Not much of a change, if you ask me.
ML6.1 (R12.1, released June 2001):
If you use break outside of a for or while loop in a MATLAB script or function,
break terminates the script or function at that point.
If break is executed in an if, switch-case, or try-catch statement, it terminates
the statement at that point.
So finally we found it: this behavior was last properly documented when there was support for Windows 95.

https://ww2.mathworks.cn/matlabcentral/answers/306791-has-use-of-break-changed-recenty

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值