clear;

N = 100000;

T{1} = [0;0] ; % Left Triangle

T{2} = [1/2;0] ; % Right Triangle

T{3} = [1/4;0.433] ; % Top Triangle

X(:,1) = [0.1; 0.1]; % initial point (Xo=0.1,Yo=0.1, is column 1 of the table)

for i = 1:N-1

Rule = floor(3*rand)+1; %Picks a random number between 1 and 8

X(:,i+1) = 1/2*X(:,i)+T{Rule};

end

figure(1);

set(gcf, 'color', 'white'); % Sets the background Color of the plot to white

% plots all points at the end

% Pick yourt preferred Dot Color from combining (0 to 1 values)

% [ r g b ] = [red green blue];

% [0 0 0] = black,

% [1 1 1] = white,

% [1 0 0 ] = red,

% [0 1 0 ] = green,

% [0 0 1 ] = blue, etc.

% What color is [0.5 0.5 0.5 ] = ?

plot(X(1,:),X(2,:),'.','Color',[0 0 1 ],'MarkerSize',2);

axis off;