%SNAPS draws the snapshots of the gBSB trajectory

% last modified  on April 11, 2001 by S. H. Zak

x_pat;

disp('               =======================')
disp('Patterns A1 through D3 were loaded into the workspace.')
disp('The weight matrix of  the gBSB net was generated using A1, B1, C1, and D1.')
disp('All this was done with the script X_PAT invoked at the beginning of the SNAPS.')
disp('               =======================')

disp('Enter your test pattern as an array, for example, as A1.')
disp('Type in P if you wish to test a randomly generated pattern.')
P_r=2*rand(5,5)-1;
P=sign(P_r);
P=input('The input pattern P=')
nn=size(P,2);
x_init=P(:);
x=x_init;
row_count=3;
col_count=3;
figure
subplot(row_count,col_count,1),abcd(P)
title('Initial pattern','Fontsize',12)
pause
   for k=1:n_iter
      x=max(min(x+alpha*W*x+alpha*b,1),-1);
       for j=1:nn
          l=(j-1)*nn+1;
          m=j*nn;
          S(:,j)=x(l:m);
       end
     disp(['Iteration ' int2str(k)])  
     S
     subplot(row_count,col_count,k+1)
     abcd(S)
     title(['Iteration ' int2str(k)])
  end