Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How do i interpret a data received serial ?

1 visualizzazione (ultimi 30 giorni)
Constantin
Constantin il 15 Mag 2013
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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.

Risposte (1)

Walter Roberson
Walter Roberson il 15 Mag 2013
You do not need to use shifting.
t = [byte1, byte2, byte3, byte4];
t_as_signed = typecast(t, 'int32');
  1 Commento
Constantin
Constantin il 15 Mag 2013
Thank You for your replay,I hope it will work.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by