%called by run_oscillate
%inhibitory-inhibitory feedback
%with leaky integrate and fire neurons
%linear synapses

function [inhib1, outi1, inhib2, outi2] = oscillate2 (inputi1, inputi2, taui1, taui2,threshi1, threshi2,steps, wi1, wi2)
inhib1(1)=0; inhib2(1)=0;old_in1=0;old_in2=0;outi1(1)=0.0; outi2(1)=0.0;
for i=2:steps
inhib1(i)=exp(-1/taui1)*old_in1+(1-exp(-1/taui1))*(inputi1(i)-wi2*outi2(i-1));
if (inhib1(i) > threshi1)
outi1(i)=1.0;
old_in1=0.0;
else
outi1(i) = 0.0;
old_in1 = inhib1(i);
end;
inhib2(i)=exp(-1/taui1)*old_in2+(1-exp(-1/taui2))*(inputi2(i)-wi1*outi1(i-1));
if (inhib2(i) > threshi2)
outi2(i) = 1.0;
old_in2 = 0.0;
else
outi2(i) = 0.0;
old_in2 = inhib2(i);
end;

end;

 

t=linspace(1,100);
for (i=1:100)
input(i)=1.0;
end;

%oscillate (input to i1, input to i2, taui1, tau i2, threshi1, threshi2, steps, wi1, wi2
%one exitatory and one inhibitory neuron, both leaky integrate continuous
[i1,oi1, i2, oi2]=oscillate2(1.0*input, 1.0*input, 5, 4, 0.8, 0.8, 100, 5.0, 5.0);
figure
plot (t,i1+5*oi1);
hold;
plot(t, i2+5*oi2, 'r');