binary=1011 decimal=bin2dec('binary')
this code shows a error - Error using bin2dec Binary string may consist only of characters 0 and 1
Is there is method for conversion of binary to decimal through passing a variable which consists binary numbers?????

댓글 수: 1

Raed Alaa
Raed Alaa 2021년 11월 15일
code matlab how to convert from binary to decimal

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

 채택된 답변

David Goodmanson
David Goodmanson 2017년 3월 29일
편집: David Goodmanson 2017년 3월 29일

0 개 추천

Hi ablaze, Your code has bin2dec trying to convert a string containing the word 'binary'. Try
a = '1011'
bin2dec(a)

댓글 수: 3

Guillaume
Guillaume 2017년 3월 29일
편집: Guillaume 2017년 3월 29일
Note that if the input is indeed numerical as shown, then
binary = 1011;
decimal = bin2dec(num2str(binary));
would work up to 15 bits. After that you're above the maximum integer value that can be stored accurately in a double (see flintmax)
It is indeed much safer to store this binary number as a string, which does not have any limit on the number of bits.
ablaze
ablaze 2017년 3월 29일
thank u
Favour Oghenekowho
Favour Oghenekowho 2021년 7월 2일
Hi, how can I convert Hexadecimal to excess 3 code using Matlab?

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 3월 29일

댓글:

2021년 11월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by