m = 40; % number of steps per animation N = 500; % number of points on each half a = []; aa = []; c = []; a = [0.5*rand(N,1) rand(N,1)]; % black points aa = [0.5 + 0.5*rand(N,1) rand(N,1)]; % green points a = [a; aa]; % concatenate them c = []; for i = 1:N, c(i) = 'k'; % color the points c(i+N) = 'g'; end c = 'kg'; figure(1) clf title('Baker''s transformation'); for r = 1:100, b = [2*a(:,1) 0.5*a(:,2)]; % locations after squash animatepoints(a,b,c,60); clf title('Baker''s transformation'); bb = [mod(b(:,1),1) b(:,2)+0.5*(a(:,1) > 0.5)]; animatepoints(b,bb,c,20); clf title('Baker''s transformation'); a = bb; end