MATLAB: The expression to the left of the equal sign is not a valid target for an assignment

MATLAB

a = 0
htext =text(0.5,0.6,'ASD')
while a = 0
delete(htext)
end
i have a coding similar to the above style, wonder why i got such problem? can anyone tell me

Best Answer

I get a different error in R2018a, specifically about:
while a = 0
Relational operators involving ‘equal’ require two symbols. To test for equality, us ‘==’, nor ‘=’.
If your code throws an error such as ‘The expression to the left of the equal sign is not a valid target for an assignment’ and it is not obvious what the error could be, always also look at the assignment immediately before it, to be certain you have not missed a closing square bracket ‘]’ on a matrix, for example, or other errors.