How read a .bin file in Matlab with known block size, block number, offset_binary and nr of samples

6 views (last 30 days)
0
I have a .bin file I'd like to read in Matlab. It contains an ASCII header with this information:
block size is 64; Block numbers is 24; offset binary is 1984; samples is 171170;
First I used fid=fopen(file) and A=fread(fid), however the size of A is a total different number than the "samples". Then I tried to use A = fread(fileID, sizeA, precision, skip, machineformat) However, I don't know the correct size, I don't know what value type to choose for precision (I think I understand it has to be 64 bits, but don't know if it's signed or unsigned or so). Also I don't know if I should use the offset binary in and samples in the formula. With everything I tried I got weird numbers. I did email the supplier of the device the file comes from, however he told me there is no Matlab knowledge there, so they could not tell me how the file is composed. Any ideas?

Answers (2)

Maria Perdomo
Maria Perdomo on 14 Feb 2014
Hi,
I had a binary file, and could oppen with the next function:
I just downloaded the function, saved it in the same directory of my file and executed it:
>> ReadLeCroyBinaryWaveform('Name.bin')
And it created the variable with the data of my binary file.

Image Analyst
Image Analyst on 14 Feb 2014
Is it an image or just some 1D list of numbers? Do you know what the data should look like if it is read properly? I'd press the manufacturer some more. How can they not know the format of their own file? That's absurd. They may not know MATLAB but they should know what the bytes in the file mean. Otherwise you'll just have to guess until you find something that works (which will be easier for an image than 1D data because it will look sheared or duplicated and you can adjust your parameters in a systematic fashion until it looks right).
  1 Comment
Marit
Marit on 17 Feb 2014
Thanks for your answer. The file is a 1D list of numbers. The data looks like the bright red line in the figures:
It is the diameter of a blood vessel in the head and it should be numbers between 40 and 70 (mm).
I contacted the manufacturer (Germany) and they forwarded my question to the Dutch supplier, which I already contacted and told me they didn't know how the information in the ASCII header (and so the .bin file) is composed. There must be somebody who knows, so indeed I'll have to press the manufacturer some more.

Sign in to comment.

Categories

Find more on File Operations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!