has use of "break" changed recenty?
7 次查看(过去 30 天)
显示 更早的评论
I have script which has functioned well under previous version of MatLab, recently updated the software to 2016a, and now get following error when running script.
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.
Has the use of the break function changed?
4 个评论
Rik
2020-12-13
Yes, all of this is from local copies (only some of these required a VM). So unfortunately the time machine in question is metaphorical. The Wayback Machine will probably not have many of these.
采纳的回答
Star Strider
2016-10-11
编辑:Star Strider
2016-10-11
It has, several versions ago. If you want to stop a script outside of a loop, use return instead of break. It does the same thing, and won’t throw an error.
To wit:
fprintf(1, 'Before ''return''\n')
return
fprintf(1, 'After ''return''\n')
EDIT — Added demonstration code snippet.
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!