Borrar filtros
Borrar filtros

Read int16 from hex file

16 visualizaciones (últimos 30 días)
Efe Berkay Yitim
Efe Berkay Yitim el 10 de En. de 2023
Respondida: Walter Roberson el 10 de En. de 2023
Hi,
I have a hex file containing 8-bit hex values which are actually 16-bit signed values. For example in the screenshot below, the values should be x27F0, x22E0, x22E0, x1D40, x1D40, x1DB0 etc. I also uploaded the hex file. (Also, even though they are signed, most of the time sign bit will be 0, ignore it please.) Now, I want to plot these data but I do not know how can I read them in the first place. Can you please help me?
  1 comentario
Rik
Rik el 10 de En. de 2023
Have you tried fread?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 10 de En. de 2023
filename = 'output2.txt';
fid = fopen(filename, 'r', 'ieee-be');
data = fread(fid, '*int16');
fclose(fid);
data(1:2)
ans = 2×1
10224 8928
dec2hex(data(1:2))
ans = 2×4 char array
'27F0' '22E0'

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by