MATLAB: How to impliment a covergence condition

conditioncovergenceiterationloop

Hi,
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
A(i)=….
end
end (for k)

Best Answer

abdel - perhaps your condtion would be
if abs(A(k,i) - A(k+1,i)) <= 0.0001
% do nothing
else
% replace your value

end
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
end
Related Question