How to unpack data with Byte Unpacking

24 ビュー (過去 30 日間)
Inna Forsiuk
Inna Forsiuk 2021 年 3 月 24 日
回答済み: Dimitri MANKOV 2022 年 7 月 7 日
Hello,
I would be happy if somebody could explain to me how to set the parameter properly in the Byte Unpacking block.
I am using Simulink Real-time, where the communication is going through a TCP socket. From TCP Receive block the data is unpacked into uint8 (which is the setting for default). I need to unpack the data via Byte Unpacking with int16. Could somebody tell me please what I have to put as the output dimension for int16?
In the attachment, I send the model to clarify the model vision.

採用された回答

Dimitri MANKOV
Dimitri MANKOV 2022 年 7 月 7 日
Hi Inna,
The "Output port dimension" parameter defines the size of the outputs produced by the "Byte Unpacking" block, as explained in the documentation. For example, suppose you receive a vector of 15 uint8 packets as an input, and you know that these packets contain the following signals:
  • 2x single (2x 32 bits / 2x 4 bytes)
  • 3x int16 (3x 16 bits / 3x 2 bytes)
  • 1x uint8 (1x 8 bits / 1x 1 byte)
You would configure the "Byte Unpack" block as follows:
  • Output data type: {['single'], ['int16'], ['uint8']}
  • Output dimension: {[2],[3],[1]}
This would generate 3 output ports for the "Byte Unpacking" block, the first being a vector of 2 single values, the second a vector of 3 int16 values and the third a uint8 signal.
In your case, you go from uint8 to int16, so the output dimension in your case would be the input dimension divided by 2.
I hope this is helpful!
Dimitri

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelopment Computer Setup についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by