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 CenterFile Exchange에서 Development Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by