% bakers(n,c) displays the first 8 iterations of the baker's map on n points with starting locations c. % Enter bakers(1000,1) at the Matlab command prompt to run it. function [void] = bakers(n,c) switch c case 1, x = 0.5*rand(1000,1); y = 0.5*rand(1000,1); case 2, x = 0.25 + 0.25*rand(1000,1); y = 0.5*rand(1000,1); case 3, x = rand(1000,1); y = x + 0.25*rand(1000,1); case 4, [x,y] = meshgrid(0:0.04:1, 0:0.04:1); x = 0.5*reshape(x,prod(size(x)),1); y = 0.5*reshape(y,prod(size(x)),1); case 5, [x,y] = meshgrid(0:0.04:1, 0:0.04:1); x = reshape(x,prod(size(x)),1)/4; y = reshape(y,prod(size(x)),1)/4; case 6, [x,y] = meshgrid(0:0.01:1, 0:0.01:1); x = reshape(x,prod(size(x)),1)/3; y = reshape(y,prod(size(x)),1)/3; case 7, x = 1/3; y = 1/3; case 8, x = [1/3 1/6]'; y = [1/3 1/6]'; end for i=1:8, subplot(4,2,2*mod(i-1,4)+1+fix((i-1)/4)) plot(x, y, '.', 'markersize', 12); axis([0 1 0 1]); title(['Iteration ' int2str(i-1)]); X = mod(2*x,1); Y = (y + (x > 0.5))/2; x = X; y = Y; end