% Cantor set via iterated function system game, p. 156. Barnett 10/27/07

f1 = @(x) x/3;
f2 = @(x) (2+x)/3;
f = {f1, f2};

N = 1e3;
x = 0.1;

nf = numel(f);                                  % number of funcs
figure;
for n=1:N
  x = f{ceil(nf*rand(1))}(x);  % trick to randomly apply one of nf funcs to x
  plot(x, 0, '.', 'markersize', 1); hold on;
  if mod(n,100)==0, drawnow; end               % only plot every 100
end

% end
