how can I groups binary digits in array element
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
dani elias
am 19 Nov. 2020
Kommentiert: Ameer Hamza
am 19 Nov. 2020
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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 19 Nov. 2020
Bearbeitet: Ameer Hamza
am 19 Nov. 2020
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!