function []=dfractal(n,s)

%DFRACTAL(n,s)
%Plots 'Dragon Curve' Fractal
%n=number of iterattions
%s=initial seed (0,1,2 or 3)
%(c) 1999 by Zak Petrucci

X=zeros(1,(2^n));
X(1)=s;
a=[0,0];

for k=1:n
m=2^k;
for h=1:m/2
X(m/2+h)=X(m/2-h+1)+1;
if X(m/2+h)==4
X(m/2+h)=0;
end
end
end

for k=1:max(size(X))
[x,y]=pol2cart((X(k)*pi/2),1);
b=a+[x,y];
line([a(1),b(1)],[a(2),b(2)])
hold on
a=b;
end
axis('equal')
axis('off')
end