function start(pattern,clean)
%put network into an activation state, determined by a corrupted version of given pattern 
%clean=1 -> pure pattern; clean=0 -> random; clean=-1 -> antipattern

global Nunits nodes patterns

noise = .5 - clean/2; %probability that each node will match the value in the ideal pattern

for i = 1:Nunits %loop units
   if rand(1) > noise
      nodes(i) = patterns(i,pattern); %node matches pattern with probability noise
   else
      nodes(i) = -patterns(i,pattern); %node mismatches pattern with probability 1-noise
   end
end

%plot network state
figure(1)
for row = 0:(sqrt(Nunits)-1)
   for column = 1:sqrt(Nunits)
      if nodes(row*sqrt(Nunits) + column)==1
         plot(column,sqrt(Nunits)-row,'sr','markerfacecolor','black','markeredgecolor','black')
      else
         plot(column,sqrt(Nunits)-row,'sy','markerfacecolor','yellow','markeredgecolor',[.8 .8 0])
      end
   end
end