Importing DAT file MATLAB

12 次查看(过去 30 天)
Ejay Nsugbe
Ejay Nsugbe 2020-11-9
Hi guys,
I'm trying to open a DAT file and I came across a rather useful snippet of code as shown below;
[filename, pathname] = uigetfile('*.dat', 'Open file .dat');% only image Bitmap
if isequal(filename, 0) || isequal(pathname, 0)
disp('File input canceled.');
ECG_Data = [];
else
fid=fopen(filename,'r');
end;
time=10;
f=fread(fid,2*360*time,'ubit12');
Orig_Sig=f(1:2:length(f));
plot(Orig_Sig)
The resulting plot looks as though the code has combined and meshed a number of columns together etc. Can anyone advise how I can import bits directly from the columns in the DAT file or best yet open the DAT file in MATLAB?

回答(1 个)

Walter Roberson
Walter Roberson 2020-11-9
The .dat file extension is used by many different programs to store data in incompatible formats. You would need to know which program produced the file and have documentation about the file format.
It would be quite unusual for data to be in packed 12 bit values. Not impossible but rarely done. It is a lot more common for 12 bit data to be stored inside 16 bit words, more typically the 12 most significant bits, but sometimes the 12 least significant bits. (You also have to worry about the bit order for packed bits.)
You talk about having meshed a number of columns together, but the way you read the data is only suitable for vector data, for which there would not be any "columns".
  2 个评论
Ejay Nsugbe
Ejay Nsugbe 2020-11-9
Walter, thanks for the reply.
The DAT file contains time-series info. from the monitoring of uterine wall contraction during pregnancy.
I know for certain, it contains signal values as mentioned, but my dillema becomes finding a way of opening the DAT file in MATLAB to extract the relevant data.
Walter Roberson
Walter Roberson 2020-11-9
Not much we as volunteers can do without documentation of the file format.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by