how can I groups binary digits in array element
3 次查看(过去 30 天)
显示 更早的评论
i have the following array with randomly binary number in sequence, but i want to divide into 4 groups of bits such as array B from A
A=[11 1 1 1 1 1 1 1 0 1 0 1 0 1 0]
to be in a form
B=[1111;1111;1010;1010]
0 个评论
采纳的回答
Ameer Hamza
2020-11-19
编辑:Ameer Hamza
2020-11-19
Try this combination of sprintf and sscanf.
A = [11 1 1 1 1 1 1 1 0 1 0 1 0 1 0];
B = sscanf(sprintf('%d', A), '%4d');
Result
>> B
B =
1111
1111
1010
1010
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!