decimal array from logical array
4 次查看(过去 30 天)
显示 更早的评论
Hi,
I need to convert a logical array into a decimal array, but the logical elements need to be grouped in pairs. An example would make this clearer:
I have a logical array such as:
>> a = logical([1,0,1,1,1,0; 1,1,0,0,0,1; 0,1,1,1,0,1])
a =
1 0 1 1 1 0
1 1 0 0 0 1
0 1 1 1 0 1
and I want to convert that to decimal with each 2 bits being 1 number:
b =
2 3 2
3 0 1
1 3 1
Does anyone know a clever/ fast MATLAB way of doing this, rather than the boring/slow for-loop way?
0 个评论
采纳的回答
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!