P = [2 1 -2 -1;2 -2 2 1];
T = [0 1 0 1];
net = newlin(P,T);
net.trainParam.goal= 0.1;
[net1,tr1] = train(net,P,T);
netp = newp(P,T);
[net1p,tr1p] = train(netp,P,T);

a = sim(net1,P);
e = sum(abs(a-T)>0.5);

ap = sim(net1p,P);
ep = sum(abs(a-T));

hold on;
plot(P(1,[1,3]),P(2,[1,3]),'or');
plot(P(1,[2,4]),P(2,[2,4]),'og');

i = -2:0.1:2;
iw = net1.IW{1,1}; b = net1.b{1,1};
j = -(iw(1,1)*i+b-0.5)/iw(1,2);
plot(i,j,'k');

iw = net1p.IW{1,1}; b = net1p.b{1,1};
j = -(iw(1,1)*i+b)/iw(1,2);
plot(i,j,'r');

hold off;