Section: Type Conversion Functions
y = bin2int(x)
where x
is a multi-dimensional logical array, where the last
dimension indexes the bit planes (see int2bin
for an example).
By default, the output of bin2int
is unsigned uint32
. To
get a signed integer, it must be typecast correctly.
--> A = [2;5;6;2] A = 2 5 6 2 --> B = int2bin(A,8) B = 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 --> bin2int(B) ans = 2 5 6 2 --> A = [1;2;-5;2] A = 1 2 -5 2 --> B = int2bin(A,8) B = 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 0 --> bin2int(B) ans = 1 2 251 2 --> int32(bin2int(B)) ans = 1 2 251 2