numCases  = 8;   %must be less than numIn
numIn     = 10;
numOut    = 5;

inputs  = rand(numCases, numIn);  %each row is a random input vector
targets = rand(numCases, numOut); %each row is a random target vector
lateral = eye(numIn);     % lateral connections start at the identity
inOut   = rand(numIn,numOut);  % initializes input-output connections

for caseNum = 1:numCases,
      input     = inputs(caseNum,:);
      novelPart = input*lateral;
      novelty   = norm(novelPart)^2;
      output    = input*inOut;
      lateral =  lateral - (novelPart' * novelPart)/novelty;
      inOut   =  inOut + novelPart' * (targets(caseNum,:)-output)/novelty;
      eig(lateral) % prints the eigenvalues of lateral
end

outputs = inputs * inOut;
targets
outputs
