How to break the iteration using an Error Equation
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a 2D for loop iteration, I want to stop the iteration once change is less than a certain number! But I don't know how to recall the previous iteration?
Let's say equation is:
Iteration i=1:20000
x=function
y=function
result is A(x,y)
How to calculate change between the A at any i and i-1?
If I want the stop iterating (break the loop) when the change is <1 for example
I don't want to use A(x,y,i) code because my iteration sometimes stop changing at 20000 or so, that will require a huge memory
Thanks in advance
0 commentaires
Réponses (1)
Walter Roberson
le 5 Déc 2013
oldvalue = inf;
for i = 1 : 200000
x = function
y = function
T = value that will go into A(x,y)
A(x,y) = T;
if abs(T - oldvalue) < Tolerance
break
end
oldvalue = T;
end
0 commentaires
Voir également
Catégories
En savoir plus sur Digital Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!