%adding hebbian learning
%create input and timeline
for t=1:100
input(t) = 1.0;
time(t) = t;
end;
%initialize weight
w(1) = 0.1;
%calculate input, output and weight change
for t=2:100
x(t) = input(t);
y(t) = w(t-1)*x(t);
w(t)=w(t-1)+0.1*x(t)*y(t);
end;
figure;
plot (time, w, 'b');hold;
plot (time, x, 'r');
plot (time, y, 'g');