//// SVM on overlapping data 
 clear; clf; 

//// training vectors
 x=[10*(rand(100,2)-0.5);rand(100,2,'normal')];
 y=[zeros(100,1);ones(100,1)];
 plot3d(x(1:100,1),x(1:100,2),2*ones(100,1),'x');
 plot3d(x(101:200,1),x(101:200,2),2*ones(100,1),'o');
 model = svmtrain(y,x);
 
//// plotting decition surface
x=[];
for x1=-5:0.1:5
    for x2=-5:0.1:5
        x=[x;x1 x2];
    end
end
y=svmpredict(ones(10201,1),x,model);
y=reshape(y,101,101);
x=meshgrid(-5:0.1:5);
surf(x,x',y,'linestyle','none'); view(0,90);
cmap=[1 1 1; 0.9 0.9 0.9]; colormap(cmap);
axis square; box on;
