uint16 to uint8
119 次查看(过去 30 天)
显示 更早的评论
Dear all,
I wonder whether there is an efficient way of converting an uint16 array of length N in an uint8 array of length 2N, so essentially replacing every 16bit word with two bytes:
e.g.
15000 => 58, 152
11000 => 42, 248.
The simplest implementation would be to convert decimal to binary string with 16 elements, and then split them 1..8 and 9...16, but I wonder if we can do another way.
Thank you in advance!
0 个评论
采纳的回答
更多回答(1 个)
Hiral Padhariya
2022-2-27
u8 = typecast(u16,'uint8');
1 个评论
Walter Roberson
2022-2-27
What difference do you perceive between your answer and what James posted 2 1/2 years ago?
另请参阅
类别
在 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!