# Problem with while-end loop [closed]

This is a peice of code written in Matlab:

while flag==1
flag = 0;
disp('end of loop');
end


Surprisingly, this does not display the string. If I remove the disp statement a figure1 window appears. Can anyone explain why?

## closed as off-topic by Bill Barth, Brian Borchers, Godric Seer, Stefano M, Christian ClasonOct 29 '13 at 7:36

This question appears to be off-topic. The users who voted to close gave these specific reasons:

If this question can be reworded to fit the rules in the help center, please edit the question.

• Since this question is more about programming than computational science, I would suggest moving it to stack overflow. – Dr_Sam Oct 28 '13 at 12:33

That is simply because flag is a defined command in matlab. Try typing flag just after having started Matlab and you will see a non-empty matrix appearing. If you type help flag you will see the meaning of that function.
Also, the function is selected by Matlab because you do not declare a variable called flag before your code. If you write flag=1 before your code, it works as expected.
myflag = 1;