how can I groups binary digits in array element

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]

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 19 日
編集済み: Ameer Hamza 2020 年 11 月 19 日

0 投票

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

2 件のコメント

dani elias
dani elias 2020 年 11 月 19 日
thank you
Ameer Hamza
Ameer Hamza 2020 年 11 月 19 日
I am glad to be of help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

質問済み:

2020 年 11 月 19 日

コメント済み:

2020 年 11 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by