MATLAB: How to read a .dat file, containing binary data

.dat filebinary data

The file is very large and ve to read by plotting those binary data without changing it to decimal format.

Best Answer

Ok. You need to open the file, for binary read access. Do that like this
fid = fopen('D:\myfile.dat','r');
Then, you need to read out what is in the file. You know the file format. You can only read out a number of bytes at a time. To read out one byte, and treat it like an unsigned 8 bit integer:
number = fread(fid,1,'*uint8');
To read out all the bytes as unsigned 8 bit integers:
numbers = fread(fid,inf,'*uint8');
That number(s) will print to screen in the range of 0 to 255. If you want to see the binary sequence that actually exists in RAM:
dec2bin(number)
To close the file:
fclose all;
Related Question