function cells1 = separaterule(cells1,x,y) for i = x for j = y rannum = rand; if cells1(i,j) > cells1(i-1,j) if rannum < 0.47 cells1(i,j) = 1; cells1(i-1,j) = 2; end elseif cells1(i,j) < cells1(i-1,j) if rannum < 0.53 cells1(i,j) = 2; cells1(i-1,j) = 1; end end end end