% by John C. Kieffer % http://www.ee.umn.edu/users/kieffer/programs.html % documented in % ftp://oz.ee.umn.edu/users/kieffer/seminar/notes1.ps % more documentation by David Cary 1999-06-26 % % See also GRAYCODE. function y = binarycode(i,L) x=[]; q=i; while q > 0 R=q-2*floor(q/2); q=floor(q/2); x=[R x]; end n=length(x); if n==L y=x; else y=[zeros(1,L-n) x]; end