Storing an int16 number into two int8 number

12 次查看(过去 30 天)
Hi All
I am new to use Matlab, and I have question regarding the data type.
I have create an array of type int8, to represent a string of byte(8 bits) in a communication channel. Some of the data written into this array may take 2 bytes, i.e number greater than 127.
So my question is, let say I have created an array of int8 of length 8, and I would like to store the number 600 in binary format in the cell 3 and 4 in this array, how to do it please?
The result I am expecting is Data = [00 00 02 58 00 00 00 00] (in Hex representation)
Thanks in advance Regards Victor

回答(1 个)

Walter Roberson
Walter Roberson 2012-11-1
typecast(int16(600),'uint8')
  2 个评论
Victor
Victor 2012-11-1
Thanks for your quick reply.
It works.
Btw, I would like to know whether Matlab can understand descending order? For example, I would like to address two cells in an array, Data(6:5).
Thanks

请先登录,再进行评论。

类别

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