mu = .001;
w = [-.2; -.2; 3];
clear errplot;

	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);

for it = 1:100
	oldw = w;
	for i = 1:250
 		x = [traina(i,:) 1]';
		y = w'*x;
		ystar = 1;
		w = w + (mu*(ystar-y)*x);
		tmp = (mu*(ystar-y)*x);

 		x = [trainb(i,:) 1]';
		y = w'*x;
		ystar = -1;
		w = w + (mu*(ystar-y)*x);
		tmp = tmp+ (mu*(ystar-y)*x);
	end

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

		tx = [testb(i,:) 1]';
		ty = w'*tx;
		err = err + (ty+1)*(ty+1);
	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);
end
