Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

How do i interpret a data received serial ?

Asked by Constantin on 15 May 2013

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.

0 Comments

Constantin

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 15 May 2013

You do not need to use shifting.

t = [byte1, byte2, byte3, byte4];
t_as_signed = typecast(t, 'int32');

1 Comment

Constantin on 15 May 2013

Thank You for your replay,I hope it will work.

Walter Roberson

Contact us