Question

I'm trying to open an image file with MATLAB (R2011b). The program which stored the bin file (Xeneth) says it has the datatype "Images (16-bit right aligned) (.png;.csv;*.bin)".

In MATLAB, I'm trying to open the file with:

fid=fopen('pathAndFile','r');
A=fread(fid,'inf','uint16');

Unfortunately, it keeps saying "Error using fread Invalid precision." An example file can be found here: https://www.dropbox.com/s/d8pj1lrhjsnbmvx/mHSdark_20ms_00014.bin

Does someone have an idea what could cause the problem?

Was it helpful?

Solution

I have the same error message in Octave and removing 'inf' solved the problem

close all; clear all;

fid = fopen('mHSdark_20ms_00014.bin');
A = fread(fid, 'uint16');
fclose(fid);

size(A)

Here is an execution result

octave:5> test
ans =

   20480       1

OTHER TIPS

This is because the optional size argument of fread is a numeric, not a string. That is, instead of 'inf', the appropriate input is just inf, a number, not a string. When you input a string to fread, it thinks you are specifying a precision instead of a size.

However, the default size is inf, which is why the argument may be omitted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top