필터 지우기
필터 지우기

how can I groups binary digits in array element

조회 수: 3 (최근 30일)
dani elias
dani elias 2020년 11월 19일
댓글: Ameer Hamza 2020년 11월 19일
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일
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개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by