% voter.m % each site accepts its neighbor's state with probability p % 4 neighbors % 4/3/3 SG clear all close all tic p = 0.1; n =100; T = 10000; plot_number_of_states = 0; c = 2; % number of colors colormap(gray(c)) % use this with c=2!!! X=ceil(c*rand(n)); % initial state: random values: 1,2,...,c image(X) axis square for t=1:T Z(1,:,:)=X; Z(2,:,:)=X(:,[n 1:n-1]); % states of neighbors left Z(3,:,:)=X(:,[2:n 1]); % states of neighbors right Z(4,:,:)=X([n 1:n-1],:); % states of neighbors above Z(5,:,:)=X([2:n 1],:); % states of neighbors below Y=rand(n); Q=1+ceil(Y.*(Y