pat=2*floor(2*rand(500,10))-1;             % Random binary pattern
w=pat*pat';                                % Hebbian learning
s=rand(500,1)-0.5;                         % Initialize network
for t=2:10; s(:,t)=sign(w*s(:,t-1)); end   % Update network
plot(s'*pat/500)
