// Sci Notebook
//hold off
clf() //close all
     //A=[.8 .2 .1;.1 .7 .3; .1 .1 .6]
     M=[0.8 0.06 0.2;0.1 0.9 0.1;0.1 0.04 0.7]; 
    A=M
//axis([0 1 0 1]);axis('square')
//plot(0,0);
//xakseli=[0 1 1 0];yakseli=[0 0 1 1];plot(xakseli,yakseli) 

// title('Markov');xlabel('a');ylabel('b');grid
// hold on
     for a=0.1:0.4:0.9,
       for b=0.1:0.4:0.9
        u=[a;b;1-a-b];
        x=u; 
        sar=1;
          while sar<=15,
          u=A*u; x=[x u];
          [riv,sar]=size(x);
         end;
  plot(x(1,:),x(2,:),x(1,:),x(2,:),'o');
//  plot3(x(1,:),x(2,:),x(3,:),x(1,:),x(2,:),x(3,:),'o');
       end;
     end;

//////////////////////////////////////

M=[0.95 0.03;0.05 0.97]
u0=[0.6;0.4]
u1=M*u0
u2=M*u1

clf()
xakseli=[0 1 1 0];yakseli=[0 0 1 1];plot(xakseli,yakseli) 
     for a=0.1:0.4:0.9,
       b=1-a
        u=[a;b];
        U=u; 
        sar=1;
          while sar<=6,
          u=M*u; U=[U u];
          [riv,sar]=size(U);
         end;
       plot(U(1,:),U(2,:),U(1,:),U(2,:),'o');
       end;
  
ua=[0.1;0.9]; ub=[0.4;0.6]; uc=[0.5;0.5]; ud=[0.7;0.3]
U0=[ua ub uc ud];
   
clf()
xakseli=[0 1 1 0];yakseli=[0 0 1 1];plot(xakseli,yakseli) 
     [m,n]=size(U0);
     for j=1:n
        U=U0(:,j); 
        sar=1;
          while sar<=10,
          u=M*u; U=[U u];
          [riv,sar]=size(U);
         end;
       plot(U(1,:),U(2,:),U(1,:),U(2,:),'o');
     end;
