MATLAB: Exiting a loop

urgent

Hello all,
I have a while loop in which
while abs(a-b)>=delta
rest of code
end
Sometimes the condition of this while loop is not satisfied and my program gets stuck in the loop; is there any way that I can specify the number of iterations such that after this specified value, my program exits the loop?
Many thanks in advance.

Best Answer

k = 0;
while abs(a-b)>=delta | k < 1e3
....
k = k + 1;
end