フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do i interpret a data received serial ?

1 回表示 (過去 30 日間)
Constantin
Constantin 2013 年 5 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I receive from serial a message(60 bytes) divided in 17 data types.I need to extract 1 data of 4 bytes.I tried to get it byte with byte,and using shifting operation I fused those 4 bytes together.The problem is that those bytes represent a signed int number and I don't know how to convert that binary number into a signed int.

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 5 月 15 日
You do not need to use shifting.
t = [byte1, byte2, byte3, byte4];
t_as_signed = typecast(t, 'int32');
  1 件のコメント
Constantin
Constantin 2013 年 5 月 15 日
Thank You for your replay,I hope it will work.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by