reading signed hex values

Hi all
I read hex values from an accelerometer : 35AC,2889,1899,0C4A,058B,FD46,F620,F001,EE44,EF08,EF46,F750,007F,0814,1369,21F3,34F0,45CE,5992,6D05,7C12,7FEF,7FF8,7FF8,7FF8,7FF8,7FD9,7F27,74A7,67D8,5826,468F,3621,2573,1326,0441,F88F,F1BF,F082,EADB,EAEE,EE04,F190,F89E,01F5,0B0C,155A,2721,3A20,48DC,5985,676A,721E,7C20,7FF8,7FEE,7F1B,
It should somehow draw a sinusoid curve, but I could not find the right import method for signed int16 and the curve jumps from 0 to 65535.
Could you please help me?
I have tried sscanf(...,'%4x')
could you please help me ?
regards
Julien

回答(2 个)

typecast(uint16(sscanf('F190', '%4x,')), 'int16')
Or:
t = sscanf('F190', '%4x,');
idx = t > 32767;
t(idx) = t(idx) - 65536;
Julien Bouchez
Julien Bouchez 2014-1-17

0 个投票

thank you
the answer was there too
regards
Julien

类别

帮助中心File Exchange 中查找有关 Specialized Power Systems 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by