
function [] = boundary(w,data,deg)

if (nargin<3), deg = 1; end;

plotdata(data); hold on;

myax = axis; 

m = 50; % grid points for contour
tx = myax(1) + (myax(2)-myax(1))*(0:m)'/m;
ty = myax(3) + (myax(4)-myax(3))*(0:m)'/m;

[n,d] = size(data.X);

Z = zeros(m+1,m+1); 
for i=1:m+1,
    X = [tx,repmat(ty(i),m+1,1)];
    Z(:,i) = w(1) + degexpand(X,deg)*w(2:end);
end;

h=contour(tx,ty,Z',[0 0],'k-'); hold off;