The problem is your invented syntax using { and }, which looks like you are trying to write code using a different programming language. In any case, you can avoid the error simply by getting rid of those pointless { and } characters, and by adding the required end at the end of the while loop.
This is also a good example of why it is important to pay attenton to the warnings shown by the MATLAB editor, which indicates in two locations that your invented syntax has some problems:
It is also a good example of how using the default code alignment helps to detect basic code bugs: if you had aligned the code using the MATLAB editor's default setting, then the code inside the while loop is clearly no longer aligned and indicates a syntax error.
It is also a good example of why it is important to read the documentation for every operator and function that you use (no matter how trivial you might think it is). Do you see any examples on the while help that look anything like the code that you wrote? (hint: no). In any case, when I run my test code I get:
When I remove the pointless { and } characters and add end, the code works without error:
while(1 < 2)
[R,C] = size(3)
end
although of course it does not stop...
Best Answer