How to Convert data from HEX codes to Numeric
    6 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
Hello, how can I convert data given in HEX codes to decimal.
- Read complete file as it is
- Output: Add a second column with values in Numeric.
0 Kommentare
Antworten (2)
  Voss
      
      
 am 9 Nov. 2023
        format long g
T = readtable('hex codes example.xlsx')
T.DecCodes = hex2dec(strrep(T.HexCodes,' ',''))
writetable(T,'hex and dec codes example.xlsx')
0 Kommentare
  Steven Lord
    
      
 am 9 Nov. 2023
        Do you mean you have the hex representation of a double precision number and want to convert it into the corresponding double? See the num2hex and hex2num functions.
Or are you trying to convert integer values? In that case see the dec2hex and hex2dec functions.
1 Kommentar
  Walter Roberson
      
      
 am 9 Nov. 2023
				hex2num() can only handle double precision . You need other approaches for single precision.
But they are unlikely to be single precision or double precision.
format long g
H2=[0xfa 0x80 0x3e 0x11 01 04 00 00]
typecast(H2, 'double')
swapbytes(ans)
typecast(H2, 'single')
swapbytes(ans)
Siehe auch
Kategorien
				Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



