In Matlab, how can I merge two bits from two columns (each column consist of one bit) into one column, for example:
X = [1,0;0,1;1,1;0,0;1,1;0,0]
The desired result is:
X = [10;01;11;00;11;00]
An easy solution would be:
b = char(X+48)
If the char array is inconvenient, you can transform it to a cell array:
bcell = cellstr(b)
char(X+'0') more easy to read.I may be thinking too easy here, but what about this:
10*X(:,1)+X(:,2)
Note that it will not actually show things like 01 as this is simplified to 1.
If you really want to show 01, you may need to process it as text:
Y=num2str(X)
Y(:,[1 end])
Xis. What you are asking for can't be done with justdoublearrays. For example, the01will be displayed as1and the00will be displayed as0.