Is there a way to read 16bit float(mantissa 8bit)bin file?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Won Geun Shin
am 2 Sep. 2022
Bearbeitet: James Tursa
am 7 Sep. 2022
I've found a function CustomFloat but I can't find a way to read the file...
it goes like this
00 00 07 00 F8 FF FD FF 01 00 01 00 01 00 FF FF
8 Kommentare
James Tursa
am 7 Sep. 2022
Bearbeitet: James Tursa
am 7 Sep. 2022
@Walter Roberson Would also need to know whether the significand is normalized to 1.0 binary or 0.1 binary. This ties in with the exponent bias, of course.
Akzeptierte Antwort
Walter Roberson
am 7 Sep. 2022
str = "00 00 07 00 F8 FF FD FF 01 00 01 00 01 00 FF FF 46 C0 B9 40"
A = sscanf(str, "%2x", [1 inf]);
if mod(numel(A), 2) == 1; A(end+1) = 0; end %pad if odd length
MSB = A(1:2:end);
mask = MSB >= 128;
MSB(mask) = MSB(mask) - 256;
LSB = A(2:2:end);
out = MSB + LSB/256;
format long g
out.'
0 Kommentare
Weitere Antworten (1)
Chunru
am 5 Sep. 2022
str = "00 00 07 00 F8 FF FD FF 01 00 01 00 01 00 FF FF"
a = sscanf(str, "%s%s", inf);
n = floor(length(a)/4)
afi = fi(0, 1, 16, 7); % signed, 16-bit word, 7-bit fraction
for i=1:n
h = a((i-1)*4 + (1:4)); % the hex from data input
afi.hex = h; % assign the hex to fi
d = afi.double; % convert to double
fprintf("%s : %f\n", afi.hex, afi.double)
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Digital Filter Analysis 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!