% Dancing on a triangle % set up the graphics screen axis('square'); axis([0 1 0 1]); hold on; % number of points to plot % (increase for a better picture) npoints = 500; corners = [ 0 1 .5; 0 0 1]; % corners of the triangle points = zeros(2,npoints); % points to plot choice = fix(3*rand(1,npoints)+1); % random choices recorded for k=2:npoints points(:,k) = (points(:,k-1) + corners(:,choice(k-1)))/2; end; plot(points(1,:),points(2,:),'.') % plot the figure