フィルターのクリア

how convert hex character into equivalent decimal number ?

1 回表示 (過去 30 日間)
Furat Alobaidy
Furat Alobaidy 2019 年 9 月 6 日
コメント済み: Walter Roberson 2019 年 9 月 9 日
Hi , i have hex number as character form , i need read its as equvialent number such as :
'B' = 11
'A' = 10
'8' =8
how can read them as decimalnumber plaease ?
clc;
b1 = hex2dec('000fff0');
b = hex2dec ('6e4efb');
format hex;
x=bitand(b1,b )
cc=dec2hex(x)
bin=hexToBinaryVector(cc)
cc=bin(end-flip(7:10)+1)
bp=num2str(cc)
bp1= bp(find(~isspace(bp))),
hex_str = dec2hex(bin2dec(bp1))
bank1= str2num(hex_str)

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 9 月 6 日
hex2dec() like you do now is correct.
Do you perhaps want to translate them digit by digit? If so then
sscanf('000fff0', '%1x', [1 inf])
  3 件のコメント
Furat Alobaidy
Furat Alobaidy 2019 年 9 月 9 日
i apologize but it still when i used hex2dec() gave me :
'B' = 4026000000000000 !!!!
it should be 'B'=11
clc;
b1 = hex2dec('000fff0');
b = hex2dec ('6e4efb');
format hex;
x=bitand(b1,b )
cc=dec2hex(x)
bin=hexToBinaryVector(cc)
cc=bin(end-flip(7:10)+1)
bp=num2str(cc)
bp1= bp(find(~isspace(bp))),
hex_str = dec2hex(bin2dec(bp1))
bank1= hex2dec(hex_str)
Walter Roberson
Walter Roberson 2019 年 9 月 9 日
??
You seem to be saying that after you do
b = hex2dec ('6e4efb');
that you want b to be decimal 11 ?? Even though you assigned a completely different value to b ??

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

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by