%niterate(wts, output, s)
%iterates a recurrent neural net eqn, returns output vector
%Oguz Yetkin 11/20/1998
%for now,works for square matrices (because of all-connected simplification)
function [output]=niterate(wts, oldoutput,s)


%wts is an N by M array, outputs is a vector of size N
n=size(wts); n=n(2);
m=size(wts);m=m(1);
output=zeros(size(oldoutput));

for i=1:n %for all neurons (stored in rows) matlab addressing is backwards 
	u=0;
	for j=1:m %do the weights (stored in columns)
		u=u+wts(i,j).*oldoutput(j);
	end
	output(i)=tanh(s.*u);
end

