annotate general/numerical/array/binary.m @ 16:db7f4afd27c5

Rearranging numerical toolbox.
author samer
date Thu, 17 Jan 2013 13:20:44 +0000
parents general/numerical/binary.m@e44f49929e56
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@16 5 % note: returns an array of uint32
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