% prvy program
xx=[3 4 -1; 3 7 -1; 8 1 -1; 5 9 -1; -1 -1 -1; -2 5 -1; -3 3 -1; 2 5 -1; 5 2 -1; 4 2 -1];
d=[-1; 1; 1; 1; -1; -1; -1; -1; 1; -1];
f1=figure;
figure(f1);
for i=1:size(xx, 1)
    if d(i)>0
        plot(xx(i, 1), xx(i, 2), 'o', 'MarkerSize', 8, 'MarkerFaceColor', 'red'); ...
    else
        plot(xx(i, 1), xx(i, 2), 'o', 'MarkerSize', 8, 'MarkerFaceColor', 'k');
    end;
hold on;
end;
w0=[1 2 3];
x1=-4:1:10; %pole od -1 do 10 s krokom 1
x2=(w0(3)-w0(1)*x1)/w0(2);
plot(x1, x2, '-m', 'LineWidth', 2);    

for k=1:50
    for ii=1:size(xx, 1)
        z=Neuron(w0, xx(ii,:))
        if z~=d(ii)
            w0=w0+0.1*(d(ii)-z)*xx(ii,:);
            %w0=w0+xx(ii,:)*0.1*(d(ii)-z)*xx(ii,:);
        end;
    end;
end;

x1=-4:1:10;
x2=(w0(3)-w0(1)*x1)/w0(2);
plot(x1, x2, '-b', 'LineWidth', 2);
axis([-4 10 -4 10]);