convert 16bit char to 4 byte hex values

11 views (last 30 days)
I have an length X 16 variable of type char. i'd like to convert it to length x 4 nibble hex values
example input: char(3x16)
1000100010001000
0000000000000010
111111111111111111
output wanted 8888
0002
FFFF

Answers (1)

Fangjun Jiang
Fangjun Jiang on 27 Jun 2023
c=char(["1000100010001000";
"0000000000000010";
"1111111111111111"])
c = 3×16 char array
'1000100010001000' '0000000000000010' '1111111111111111'
d=dec2hex(bin2dec(c))
d = 3×4 char array
'8888' '0002' 'FFFF'
  4 Comments

Sign in to comment.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!