Use a while loop:
lastvalue = Inf;
newvalue = -Inf;
while newvalue ~= lastvalue
lastvalue = newvalue;
newvalue = ... %the result of your calculation
end
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!