How to break the iteration using an Error Equation
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2013 年 12 月 5 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Digital Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!