MATLAB Answers

abdel m

How to impliment a covergence condition?

Asked by abdel m
on 20 May 2019 at 15:45
Latest activity Commented on by Geoff Hayes
on 22 May 2019 at 11:13
How can i impliment a convergence condition in a loop. (the condition is A(k,i)-A(k+1,i)<=0.0001)
and with another condition :( if the condition is true continue, else replace the the last value and repeat).
for emample:
for k=1:t (time loop)
for i=1:10
end (for k)


Sign in to comment.

1 Answer

Answer by Geoff Hayes
on 20 May 2019 at 19:11
 Accepted Answer

abdel - perhaps your condtion would be
if abs(A(k,i) - A(k+1,i)) <= 0.0001
% do nothing
% replace your value
Since we do nothing if the condition is true, we could simplify the above code to
if abs(A(k,i) - A(k+1,i)) > 0.0001
% replace your value


i tried this, but it take a lot of time without give any result.
maybe this is the wrong condition to use then. Try stepping through the code with the debugger to understand why you might not be getting a result.

Sign in to comment.