필터 지우기
필터 지우기

how to get every byte value of a double datatype?

조회 수: 19 (최근 30일)
Aniket
Aniket 2013년 5월 13일
I have a 8 byte input signal to a model. I want to extract every byte of that signal. How can I do it?

채택된 답변

David Sanchez
David Sanchez 2013년 5월 13일
These two MATLAB functions might be of help:
str = dec2bin(d,n) produces a binary representation with at least n bits.
str = dec2hex(d, n) produces a hexadecimal representation with at least n digits.

추가 답변 (1개)

Matthew Doveton
Matthew Doveton 2013년 5월 13일
I think this may be what you are after, converts a double to a byte array.
Data_In = double(floor(rand(1)* 10000)); %test double
Byte_Array = typecast(uint64(Data_In), 'uint8') %get byte array
I have only had MATLAB for a couple of days so am extremely new to it. I'm sure that this will most probably not be the ideal way to do this, not sure.
You may need to reverse the array depending on your endian preference.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by