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!

 채택된 답변

James Tursa
James Tursa 2019년 7월 30일

0 개 추천

u16 = your uint16 variable
u8 = typecast(u16,'uint8');

추가 답변 (1개)

Hiral Padhariya
Hiral Padhariya 2022년 2월 27일

0 개 추천

u8 = typecast(u16,'uint8');

댓글 수: 1

Walter Roberson
Walter Roberson 2022년 2월 27일
What difference do you perceive between your answer and what James posted 2 1/2 years ago?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by