%Outline of a main program for simulation of the Ising model
%
%Mats K 010208

%The parameter called the inverse temperature:
beta=.5;
%The size of the square image:
N=64;
%Start image:
I=rand(N)<.5;
%K=the total number of iterations:
K=100;

for s=1:K
   %The two loops below constitute a `sweep'
   for k=1:N
       for l=1:N
          
          %First: look up the neighbours to I(k,l)
          %Don't forget to take care of the periodic
          %boundaries:
          n=neighbours(I,[l,k]);
          
          %Now, sample from the conditional distribution:          
          I(k,l)=update_ising(n,beta);
       
       end
   end
   
   %Show the result from this sweep and pause for .1 seconds
   %This step should be erased when you see that it works 
   %as it should.
   
   imshow(I),pause(.1)
end
imshow(I)

