How to combine two binary columns

9 次查看(过去 30 天)
I have a table like this: [0 1 0 0 1, 1 0 1 1 0]
and i want to combine binary the two columns in order to obtain a column like this:
[01, 10, 01, 01, 10]. Ho can I do this?

采纳的回答

Fangjun Jiang
Fangjun Jiang 2022-10-12
编辑:Fangjun Jiang 2022-10-12
a=[0 1 0 0 1;1 0 1 1 0]
a = 2×5
0 1 0 0 1 1 0 1 1 0
s=sprintf('%d%d\n',a(:))
s =
'01 10 01 01 10 '
Or
b=dec2bin(a)
b = 10×1 char array
'0' '1' '1' '0' '0' '1' '0' '1' '1' '0'
c=reshape(b,2,[])
c = 2×5 char array
'01001' '10110'
d=c'
d = 5×2 char array
'01' '10' '01' '01' '10'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by