function M=sierrand(z)
%Sierpinski triangle via chaos game.  -JJL
if size(z)~=[2 1],error('Incorrect data format'),end
z1=z(1);z2=z(2);  if z1<0 | z2<0,error('Restrict data to first quadrant'),end
top=cos(pi/6);
r=rand;
if r<.3333,        %Marker point (0,0).
  z1=.5*z1;z2=.5*z2;
elseif r<.6667,    %Marker point (1,0).
  z1=.5*(z1+1);z2=.5*z2;
else               %Marker point (.5,cos(pi/6)).
  z1=.5*(z1+.5);z2=.5*(z2+top);
end
x=[0,.5,1,z1];y=[0,top,0,z2];
plot(x,y,'.'),hold on
M=[z1,z2]';
