Stop Itration of a matric when it converges
조회 수: 3 (최근 30일)
이전 댓글 표시
My matrix is iterating with each element using same equation. I want to stop the iteration at convergence. My code (below) is not stopping no matter what. Can someone please help me out?
probability = (ones(1,2048) .* 1/2048);
Tij = sum(StateTransitionfwd);
Tji = sum(StateTransitionbwd);
p = ((Tji .* probability) - (Tij .* probability));
threshold = (zeros(1,2048));
old = p;
new = zeros(1,2048);
while true
p = ((p * StateTransitionbwd) - (Tij .* p));
new = p;
if old-new <= threshold
break
end
old = p;
%old - new = threshold;
end
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!