% sequence generator
%
%   supply the law and it returns a column vector of binary bits
%
%   04Feb97..first ever matlab function that I wrote..K.Metzger
%
function [bit]=seq(law)
digit=[];
while law~=0
   digit=[digit,rem(law,10)];
   law=floor(law/10);
end
power=8.^(0:(sum(ones(size(digit)))-1));
value=sum(digit.*power);
digit=[];
while value~=0
   digit=[digit,rem(value,2)];
   value=floor(value/2);
end
n=sum(ones(size(digit)))-1;
L=2^n-1;
content=zeros(1,n);
content(1)=1;
digit=digit(1:n);
bit=[];
while L~=0
   if content(n)~=0
      bit=[bit;1];
      content=[0,content];
      content=content(1:n);
      content = xor(content,digit);
   else
      content=[0,content];
      content=content(1:n);
      bit=[bit;0];
   end
   L=L-1;
end
