Stop Itration of a matric when it converges

3 visualizaciones (últimos 30 días)
Salman Saeed
Salman Saeed el 24 de Ag. de 2015
Comentada: Salman Saeed el 28 de Ag. de 2015
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

Respuestas (1)

Walter Roberson
Walter Roberson el 24 de Ag. de 2015
Try
if abs(old-new) <= threshold
  4 comentarios
Salman Saeed
Salman Saeed el 28 de Ag. de 2015
Basically I am working on the cell cycle. I am attaching the paper I am working on. Please have a look at equation 4 and its description. I have the transition probabilities of all the states. So basically in this loop I am trying to iterate equation 4.
Thank you so much for helping me out.
Salman Saeed
Salman Saeed el 28 de Ag. de 2015
and here is my code

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by