Storing an int16 number into two int8 number

12 vues (au cours des 30 derniers jours)
Victor
Victor le 1 Nov 2012
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

Réponses (1)

Walter Roberson
Walter Roberson le 1 Nov 2012
typecast(int16(600),'uint8')
  2 commentaires
Victor
Victor le 1 Nov 2012
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
Walter Roberson
Walter Roberson le 1 Nov 2012
Data([6 5])
or
Data(6:-1:5)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by