function cantor(x1,x2,y1,y2,k)
%function cantor(x1,x2,y1,y2,k)
%k is the "depth counter"
%implement with figure;hold on;cantor(0,1,0,1,10)
x=x1:(x2-x1)/3:x2;
ym=(y1+y2)/2;
plot([x(2) x(3)],[ym ym]); axis([0 1 0 1]),drawnow
if k>1
    k=k-1; %depth levels remaining
    cantor(x(1),x(2),y1,ym,k);
    cantor(x(3),x(4),ym,y2,k);
end

