%%Created by: Chris Wilwand
%%EPS109, Instructor: Burkhard Militzer, Fall 2009
%%Cantor Dust in 2d

n=12
x=[0 1];
y=[0 0];
z=[1]
imagesc(z);
set(gca,'YDir','normal');
colormap(1-gray);
axis tight;
pause

for j=1:n
    iteration=j
    m=2^j;
    for i=m+1:2*m
        x(i)=x(i-m)+2*(3^(j-1));
    end
    z=zeros(3^j,3^j)
    for f=2:2:2*m
        for g=2:2:2*m
            z(x(f),x(g))=1
        end
    end
    imagesc(z);
    set(gca,'YDir','normal');
    colormap(1-gray);
    axis tight;

    pause
end