By default, fread reads a file 1 byte at a time, interprets each byte as an 8-bit unsigned integer (uint8), and returns a double array.
So you need to convert it to binary array.
To convert a number to binary array de2bi is used in matlab
For example
de2bi(1,8)
ans =
1 0 0 0 0 0 0 0
it reutrns an 8 bit binary array (as i specified it in 2nd argument) and msb is on right.
Now if i have two numbers
de2bi([1 2],8)
ans =
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
Also if you want to read double from binary file you can directly use
fread(fileID,'double')
For example
I write a double value 0.101 in binary file doubledata.bin
fileID = fopen('doubledata.bin','w');
fwrite(fileID,0.101,'double');
fclose(fileID)
Now i am reading it
fileID = fopen('doubledata.bin');
fread(fileID,'double')
ans =
0.1010