I need to convert hexadecimal values into signed decimal values,

31 ビュー (過去 30 日間)
VIJETH J SHETTY
VIJETH J SHETTY 2021 年 12 月 23 日
コメント済み: VIJETH J SHETTY 2021 年 12 月 24 日
  1. I have a log file(data.log) which contain arrays of(52X1)hexadecimal values.
  2. Data is saved like this in the log file
F29E031C
F398031C
F3220376
F2220376........
3. first I need to import these values into the matlab
4. Then i need split this 8 charecter cell into 2 rows (like F29E031C = F29E 031C)
5.Finally i need to convert these values into 16bit signed decimal
(for example:
F29E031C = F29E 031C
convetred -3426 796
)

採用された回答

Walter Roberson
Walter Roberson 2021 年 12 月 23 日
S = 'F29E031C'
S = 'F29E031C'
typecast(uint16(sscanf(S, '%4x')),'int16')
ans = 2×1
-3426 796
Except replace the assignment to S with
S = fileread('YourFileName.log');
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 12 月 23 日
S = 'F29E031C F398031C F3220376 F2220376'
S = 'F29E031C F398031C F3220376 F2220376'
i16_values = typecast(uint16(sscanf(S, '%4x')),'int16')
i16_values = 8×1
-3426 796 -3176 796 -3294 886 -3550 886
two_columns = reshape(i16_values, 2, []).'
two_columns = 4×2
-3426 796 -3176 796 -3294 886 -3550 886
VIJETH J SHETTY
VIJETH J SHETTY 2021 年 12 月 24 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEvent Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by