Mercurial > hg > ishara
annotate general/numerical/binary.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
author | samer |
---|---|
date | Sat, 12 Jan 2013 19:21:22 +0000 |
parents | |
children |
rev | line source |
---|---|
samer@4 | 1 % binary - return array contain binary sequece over N columns |
samer@4 | 2 % |
samer@4 | 3 % binary :: N:natural -> [[2^N,N]->{0,1}]. |
samer@4 | 4 % |
samer@4 | 5 % note: returns an array of uint8 |
samer@4 | 6 |
samer@4 | 7 function B=binary(N) |
samer@4 | 8 |
samer@4 | 9 M=2^N; |
samer@4 | 10 B=zeros(M,N,'uint8'); |
samer@4 | 11 b=1:N; |
samer@4 | 12 for i=1:M |
samer@4 | 13 B(i,:)=bitget(uint32(i-1),b); |
samer@4 | 14 end |