how to check convergence

38 ビュー (過去 30 日間)
Dion Liu
Dion Liu 2018 年 9 月 5 日
コメント済み: KSSV 2018 年 9 月 5 日
I want to stop this while loop if the means array does not change anymore, so basically when convergence occurs.
while i <= maxIterations
k = size(seedMeans,1);
means = UpdateMeans(A,k, clusters);
i = i+1;
How should I do this?

採用された回答

KSSV
KSSV 2018 年 9 月 5 日
YOu have to proceed something like this:
means0 = 0 ;
while i <= maxIterations
k = size(seedMeans,1);
means = UpdateMeans(A,k, clusters);
dm = means0-means ;
means0 = means ;
if abs(dm)<=10^-3
break
end
i = i+1;
end
  7 件のコメント
Dion Liu
Dion Liu 2018 年 9 月 5 日
all right thanks so much
KSSV
KSSV 2018 年 9 月 5 日
Thanks is accepting answer..:)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by