MATLAB: How to define binary matrix in matlab

binarymatrix

let's suppose that i have this matrix
A=[0001
0010;
0011;
0100;
0101]
how can i define it to matlab so that it will be reconized as binary matrix and not double ?

Best Answer

If you mean that you type in the A matrix exactly as above, but want to reinterpret the decimal digits as binary digits, then maybe something like this:
>> A=[0001
0010;
0011;
0100;
0101]
A =
1
10
11
100
101
>> bin = reshape(sprintf('%04d',A),4,[])'
bin =
0001
0010
0011
0100
0101
If you wanted that as a logical matrix instead of a char matrix, then
bin = (bin == '1')