Test based on inequality of two vectors does not succeed.
Show older comments
([1,0],[0.8,0.2;0.6,0.4])
function stationarystates( S0,T )
%This function is a simple model of a Markov chain
% S0 is the initial state
% T is the transition matrix
% I want the cumulation of states to stop after state i if state i =
% state i+1. This does not happen with this code
M=S0
for i=1:1:10
if S0*T^i~=S0*T^(i-1) %Test for inequality of successive states
M((i+1),:)=S0*T^i; %M cumulates the states
else break
end
end
disp(M)
plot(M)
end
1 Comment
Massimo Zanetti
on 31 Oct 2016
Adding some explanation to summarize your problem?
Accepted Answer
More Answers (1)
Categories
Find more on Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!