MATLAB: Has use of “break” changed recenty

olddocsupdateused break when i should use return

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?

Best Answer

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.