I want to iterate all of the elements in my matrix and want them to stop when the value converges of all the elements. I wrote the code (below) but its giving me wrong values and i dont think if values are actually going in the loop.
probability = (ones(1,2048) .* 1/2048); %vector of 2048 values
Tij = sum(StateTransitionfwd); %vector of 2048 values
Tji = sum(StateTransitionbwd); %vector of 2048 values
p = ((Tji .* probability) - (Tij .* probability)); %vector of 2048 values
threshold = (zeros(1,2048)); %vector of 2048 values
old = p; %vector of 2048 values
new = zeros(1,2048); %vector of 2048 values
while old - new > threshold %subtracting vector from the vector
old = p;
p = ((p * StateTransitionbwd) - (Tij .* p));
new = p;
end