How I can Convert Decimal number into binary number then to matrix binary number ?

조회 수: 2 (최근 30일)
e,g I have 128125
i want convert to 01 1111 0100 0111 1000
then convert to 01
11
11
01
00
01
11
10
00

채택된 답변

John D'Errico
John D'Errico 2021년 12월 21일
Easy peasey.
B = dec2bin(123125)
B = '11110000011110101'
B = [repmat('0',rem(length(B),2)),B]
B = '011110000011110101'
reshape(B,2,[])'
ans = 9×2 char array
'01' '11' '10' '00' '00' '11' '11' '01' '01'
  댓글 수: 2
Abduellah Elbakoush
Abduellah Elbakoush 2021년 12월 21일
thank you so much , but I want to put them into matrix such as image matrix or text matrix
Walter Roberson
Walter Roberson 2021년 12월 21일
B = dec2bin(123125)
B = '11110000011110101'
B = [repmat('0',rem(length(B),2)),B]
B = '011110000011110101'
reshape(B,2,[])' - '0'
ans = 9×2
0 1 1 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by