mu = .003;
w = [ 0;  1; 0];
clear errplot;

for it= 1:100
	for i = 1:250
		x= [traina(i,:) 1]';
		y = w'*x;
		if(y > 0)
			yr=1;
		else
			yr=0;
		end
		ystar = 1;
		w = w + (mu*(ystar-yr)*x);

		x= [trainb(i,:) 1]';
		y = w'*x;
		if(y > 0)
			yr=1;
		else
			yr=0;
		end
		ystar = 0;
		w = w + (mu*(ystar-yr)*x);
	
	end

	err = 0;
	for i = 1:250
		tx = [testa(i,:) 1]';
		ty = w'*tx;
		if(ty > 0)
			ty = 1;
		else
			ty = 0;
		end
		err = err + (ty-1)*(ty-1);

		tx = [testb(i,:) 1]';
		ty = w'*tx;
		if(ty > 0)
			ty = 1;
		else
			ty = 0;
		end
		err = err + (ty)*(ty);
	end
	errplot(it) = err;
	it
	w
	hold off
	xes = -2:.1:4;
	yes = -w(1)*xes/w(2) - w(3)/w(2);
	plot(xes, yes);
	hold on
	plot(traina(:,1), traina(:,2), 'redx');
	plot(trainb(:,1), trainb(:,2), 'blueo');
	hold off
	pause(.1);
%	hold
end