Convert/copy array to different type of array (single to uint16 for example) bit by bit

조회 수: 2 (최근 30일)
Hey folks,
is there a way to copy an array to another array bit by bit?
For example:
x = single(zeros(1,100));
y = uint16(ones(1,200));
What I want to do is to copy the array y bit by bit to array x. In the end x should be something like [257 257 257... 257].
single: 0000 0000 0000 0000 = 0
uint16: 0000 0001 0000 0001 = 1 1
If y get's copied bit by bit to x, the result should be something like:
single: 0000 0001 0000 0001 = 257
Is there a way to do this?
A for loop is not what I'm looking for and the bitor function doesn't work because of different sizes...
Thanks in advance.

채택된 답변

Steven Lord
Steven Lord 2020년 9월 24일
Are you trying to typecast one of the variables into the other?

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by