function S=fern(A)
%Barnsley fern.  -JJL
if nargin==0,A=[0 0]';end
[M,N]=size(A);
if M~=2,error('Incorrect data format'),end;
b2=repmat([0 1.6]',1,N);
b3=repmat([0 1.6]',1,N);
b4=repmat([0 .44]',1,N);
y1=[0 0;0 .16]*A;
y2=[.85 .04;-.04 .85]*A+b2;
y3=[.2 -.26;.23 .22]*A+b3;
y4=[-.15 .28;.26 .24]*A+b4;
x=[y1(1,:),y2(1,:),y3(1,:),y4(1,:)];y=[y1(2,:),y2(2,:),y3(2,:),y4(2,:)];
plot(x,y,'.')
if nargout>0,S=[x;y];end
