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일

2 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

질문:

2018년 5월 3일

댓글:

Jan
2018년 5월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by