reading signed hex values
Show older comments
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

Answers (2)
Walter Roberson
on 17 Jan 2014
typecast(uint16(sscanf('F190', '%4x,')), 'int16')
Or:
t = sscanf('F190', '%4x,');
idx = t > 32767;
t(idx) = t(idx) - 65536;
Julien Bouchez
on 17 Jan 2014
0 votes
Categories
Find more on Specialized Power Systems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!