% Hebb rule with 2 D rotated input eta=0.1; theta=pi/3; R=[cos(theta),sin(theta);-sin(theta),cos(theta)]; sig1=1; sig2=0.3; Iterations =300; figure hold on w=0.01*rand(2,1); w_all=w; Q=zeros(2); axis 'square' for ii=1:Iterations x1=sig1*(2*rand-1); x2=sig2*(2*rand-1); x=[x1,x2]*R; Q=Q+x'*x; plot(x(1),x(2),'+'); y=x*w; w=w+eta*(y*x'-y^2*w); %w=[w,w_new] w_all=[w_all,w]; plot(w(1),w(2),'or') pause(.02) drawnow end Q=Q/Iterations [a,b]=eig(Q) h1=plot([0 a(1,2)],[0 a(2,2)],'g') h2=plot([0 a(1,1)],[0 a(2,1)],'-.k') set(h1,'LineWidth',3) set(h2,'LineWidth',3)