function [x,y] = cantor(n)
% [X,Y] = CANTOR(N) calculates, returns and draws the edge points
% of the n-th iteration of the Cantor set.
% [X,Y] = CANTOR uses n = 5.
% This file was generated by students as a partial fulfillment
% for the requirements of the course "Fractals", Winter term
% 2004/2005, Stuttgart University.
% Author : Jonas Offtermatt
% Date : Nov 2004
% Version: 1.0
%default setting
if nargin ~= 1
n = 4;
end
% end of recursion
if n <= 0
x = [0 1];
y = [0 0];
% recursive method call
else
[x0,y0] = cantor(n-1);
% calculate new co-ordinates
x = (1/3)*[x0 x0+2];
y = [y0 y0];
end
plot(x,y,'.');
hold off;