Consider M = 2
, N = 3
as an example. Then power(2,N*M)-1
is 63
, and 0:power(2,N*M)-1
is the vector [0 1 2 ... 63]
.
dec2base(..., 2)
converts those 64
numbers into base 2
, using chars '0'
and '1'
as "digits". Each result is in a row, left-padded with '0'
's if needed. So it gives the 64
×6
char matrix
000000
000001
000010
....
111110
111111
To convert those chars into numbers, subtract '0'
. That gives 0
for '0'
and 1
for '1'
, exploiting the fact that the ASCII codes for chars '0'
and '1'
are consecutive. So the final result is the numeric matrix
0 0 0 0 0 0
0 0 0 0 0 1
0 0 0 0 1 0
....
1 1 1 1 1 0
1 1 1 1 1 1
dec2base
internally does, typeopen dec2base
and see. Be careful not to modify anything. If what confuses you is some other part, please specify in your question – Luis Mendo2^(M*N) x (M*N)
matrix. The- '0'
converts the char output ofdec2base
to numeric. – beaker