reading signed hex values

조회 수: 14 (최근 30일)
Julien Bouchez
Julien Bouchez 2014년 1월 17일
답변: Julien Bouchez 2014년 1월 17일
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개)

Walter Roberson
Walter Roberson 2014년 1월 17일
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일
thank you
the answer was there too
regards
Julien

카테고리

Help CenterFile Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by