MATLAB: Undefined function or variable

undefined function or variable

I got error as stated below, your assistance would be greatly appreciated, Thank you
A=3e3;
B=2e3;
while (abs(A-B))<50
x=4*A;
y=B*A*3;
end
x
y
****** Undefined function or variable 'x'.
Error in ddff (line 7) x
********

Best Answer

UTS, with those values for A and B you never enter the loop and therefore no values are assigned to x, which is why it is not defined.
One thing you could do is initialize x and y to zero before the loop.