Read a binary file of format float

75 views (last 30 days)
Alon on 3 Jun 2015
Commented: Alon on 3 Jun 2015
Hello, I have a binary file that holds a content of float array that wa written in c#. I want to read it into matlab to view that float array. I think I need to use the next command but it seems to fail:

Answers (2)

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 3 Jun 2015
Edited: Salaheddin Hosseinzadeh on 3 Jun 2015
Hi Alon,
As a C# programmer you know that "it fails" is not enough!
BTW, sometime when I want to generate a file specially on drive C, I have to open MATLAB as an administrator! You may wanna to this as well.
Alon on 3 Jun 2015
Edited: Alon on 3 Jun 2015
I do it that way:
fid = fopen('myRecordBin.bin', 'r');
Now, I can read it and matlab's workspace show 69222 elements and in the vector it shows: 69222x1 double.
But my original float array(and not double) in c# is twice: 138444 elements.

Sign in to comment.

James Tursa
James Tursa on 3 Jun 2015
Did you open the file first to obtain a valid fID? Are you getting an error message? (If so, please post the entire message). Are you getting garbage for myfloat? (Indicating possible endian problem, or maybe header data not accounted for, or data is not really float, etc.)
Alon on 3 Jun 2015
Hello! Thanks for you pleasing answers. I got my problem, here we go:
fid = fopen('myRecordBin.bin', 'r');

Sign in to comment.


Find more on Programming Utilities in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!