Undefined function or variable

9 views (last 30 days)
UTS on 9 Feb 2014
Commented: Mischa Kim on 9 Feb 2014
I got error as stated below, your assistance would be greatly appreciated, Thank you
while (abs(A-B))<50
****** Undefined function or variable 'x'.
Error in ddff (line 7) x

Accepted Answer

Mischa Kim
Mischa Kim on 9 Feb 2014
Edited: Mischa Kim on 9 Feb 2014
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.
Mischa Kim
Mischa Kim on 9 Feb 2014
Right, as I pointed out above, with A = 3000 and B = 2000 you never enter the loop, since 3000 - 2000 > 50. Try for example A = B = 3000. Note, however, that you are neither changing A nor B inside the loop. This means that the loop condition is always satisfied and you're stuck in an endless loop.

Sign in to comment.

More Answers (0)


Find more on Simulink in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!