function fern
figure;
axis([-3 3 0 10])
axis off
darkgreen = [0 2/3 0];
x = [.5; .5];
plot(x(1),x(2),'.g','markersize',3,'color',darkgreen);

p  = [ .85  .92  .99  1.00];
A1 = [ .85  .04; -.04  .85];  b1 = [0; 1.6];
A2 = [ .20 -.26;  .23  .22];  b2 = [0; 1.6];
A3 = [-.15  .28;  .26  .24];  b3 = [0; .44];
A4 = [  0    0 ;   0   .16];

for i=1:30000
   r = rand;
   if r < p(1)
      x = [x,A1*x(:,end) + b1];
   elseif r < p(2)
      x = [x,A2*x(:,end) + b2];
   elseif r < p(3)
      x = [x,A3*x(:,end) + b3];
   else
      x = [x,A4*x(:,end)];
   end
  end
 plot(x(1,:),x(2,:),'.','markersize',3,'color',darkgreen);