# How to impliment a covergence condition?

1 visualizzazione (ultimi 30 giorni)
m m il 20 Mag 2019
Commentato: Geoff Hayes il 22 Mag 2019
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)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Geoff Hayes il 20 Mag 2019
abdel - perhaps your condtion would be
if abs(A(k,i) - A(k+1,i)) <= 0.0001
% do nothing
else
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
end
##### 2 CommentiMostra NessunoNascondi Nessuno
m m il 21 Mag 2019
i tried this, but it take a lot of time without give any result.
Geoff Hayes il 22 Mag 2019
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.

Accedi per commentare.

### Categorie

Scopri di più su Function Creation in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by