How do i convert data to 2 bit hexadecimal using num2hex?
6 次查看(过去 30 天)
显示 更早的评论
I am using num2hex where i am getting 8 bit as the output, i need to convert it to 2 bit. is there any way for that using num2hex? example :ffc00000, this is the output of 8 bit, how do i convert it to 2 bit?
回答(1 个)
Walter Roberson
2017-7-31
LUT{'0'} = {'00' '00'};
LUT{'1'} = {'00', '01'};
LUT{'2'} = {'00', '10'};
LUT{'3'} = {'00', '11'};
LUT{'4'} = {'01', '00'};
LUT{'5'} = {'01', '01'};
LUT{'6'} = {'01', '10'};
LUT{'7'} = {'01', '11'};
LUT{'8'} = {'10' '00'};
LUT{'9'} = {'10', '01'};
LUT{'A'} = {'10', '10'};
LUT{'B'} = {'10', '11'};
LUT{'C'} = {'11', '00'};
LUT{'D'} = {'11', '01'};
LUT{'E'} = {'11', '10'};
LUT{'F'} = {'11', '11'};
LUT{'a'} = {'10', '10'};
LUT{'b'} = {'10', '11'};
LUT{'c'} = {'11', '00'};
LUT{'d'} = {'11', '01'};
LUT{'e'} = {'11', '10'};
LUT{'f'} = {'11', '11'};
hex = num2hex(single(ScalarValue));
output = [LUT{hex}];
The output would be, for example,
{'11' '11' '11' '11' '11' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00' '00'}
You were not clear on what value you wanted for each output. If you want numeric values such as 0, 1, 2, 3 then you can code those instead of the '10' or whatever.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!