• Remix
  • Share
  • New Entry

on 29 Oct 2021
  • 4
  • 42
  • 0
  • 0
  • 279
n=1e5;
a=[-1,-1];
b=[-1,1];
c=[1,1];
d=[1,-1];
r=@randi;
figure('Color',[.1,.2,.3]);
hold
Current plot held
P=zeros(n,2);
p=c/2;%select some random point within the square
s=0;
for i=1:n
R=r(4);
while s==R
R=r(4);
end
s=R;
switch R
case 1
q=a;
case 2
q=b;
case 3
q=c;
case 4
q=d;
end
p=(p+q)/2;
P(i,:)=p;
end
plot(P(:,1),P(:,2),'Col','w','LineS','n','Marker','.','MarkerS',1);
axis equal off;
Remix Tree