how to convert hex array to decimal array ?

14 ビュー (過去 30 日間)
tomer polsky
tomer polsky 2018 年 5 月 3 日
コメント済み: Jan 2018 年 5 月 3 日
hello i want to convert hex number to dec for exmaple :
a=hex2dec('d2')
now i want an array of hex numbers for exmaple :[ d1 d2 d4 cf ] how can i convert this array ?

採用された回答

Stephen23
Stephen23 2018 年 5 月 3 日
編集済み: Stephen23 2018 年 5 月 3 日
One char vector, fixed length hexadecimal, no spaces:
>> sscanf('d1d2d4cf','%2x')
ans =
209
210
212
207
One char vector, any length, space characters:
>> sscanf('d1 d2 d4 cf','%x')
ans =
209
210
212
207
From one cell array, any length char vectors:
>> C = {'1','d2','d4','cf'};
>> sscanf(sprintf('%s\v',C{:}),'%x\v')
ans =
1
210
212
207
  2 件のコメント
tomer polsky
tomer polsky 2018 年 5 月 3 日
thank you very mach it's working
Jan
Jan 2018 年 5 月 3 日
sscanf is much more efficient than dec2hex. +1

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by