function setuplines

%this function initializes the network and defines the patterns

global Nunits nodes synapses Npatterns patterns

Nunits = 1024;
nodes = zeros(Nunits,1);
synapses = zeros(Nunits,Nunits);
Npatterns = 10;
patterns = zeros(Nunits,Npatterns)+1;

figure(1)
hold on
axis([1 sqrt(Nunits) 1 sqrt(Nunits)])

%define the patterns, as 1s and -1s

for i=1:32
   for j=1:32
      node = j+32*(i-1);
      if round(i/2)==round(i)/2
         patterns(node,1)=-1;
      end
      if round(round(i/2)/2)==round(round(i/2))/2
         patterns(node,2)=-1;
      end
      if round(round(i/4+.3)/2)==round(round(i/4+.3))/2
         patterns(node,3)=-1;
      end
      if round(round(i/8+.4)/2)==round(round(i/8+.4))/2
         patterns(node,4)=-1;
      end
      if round(round(i/16+.45)/2)==round(round(i/16+.45))/2
         patterns(node,5)=-1;
      end
      if round(j/2)==round(j)/2
         patterns(node,6)=-1;
      end
      if round(round(j/2)/2)==round(round(j/2))/2
         patterns(node,7)=-1;
      end
      if round(round(j/4+.3)/2)==round(round(j/4+.3))/2
         patterns(node,8)=-1;
      end
      if round(round(j/8+.4)/2)==round(round(j/8+.4))/2
         patterns(node,9)=-1;
      end
      if round(round(j/16+.45)/2)==round(round(j/16+.45))/2
         patterns(node,10)=-1;
      end
   end
end

      
