% markov2 - simulates a two-state Markov process
% version 1
% Lance Williams 
% Dept. of Computer Science
% Univ. of New Mexico
%

function [P,v]=markov2(a,b,x0);

P=[1-a, b; a, 1-b];

x(1:50) = 0;
y(1:50) = 0;

v(1) = x0;
v(2) = 1-x0;

for n=1:50
  x(n) = v(1);
  y(n) = v(2);
  v=P*v;
end
  
mplot(1:50,x,1:50,y);