I have single value(val=2) written as 24 bit data using matlab as:
fid = fopen('.\t1.bin'), 'wb');
fwrite(fid, val, 'bit24', 0);
In a bin viewer, I can see that data (value 2) is stored as 02 00 00. I need to read value as single integer in python. my code below does not work:
struct_fmt = '=xxx'
struct_unpack = struct.Struct(struct_fmt).unpack_from
with open('.\\t1.bin', mode='rb') as file:
fileContent = file.read()
res = struct_unpack(fileContent)
I also tried
val = struct.unpack('>I',fileContent)
but it give error:
unpack requires a string argument of length 4
What am i doing wrong?
Thanks
sedy