error in opening MIT ecg database

1 次查看(过去 30 天)
hello,
I want read and plot ECG signal downloaded from MIT data base (.dat) i use the following codes:
clear all
clc
close all
[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)
Orig_Sig=f(1:length(f));
%plot(Orig_Sig(1:2:length(f)))
plot(Orig_Sig(1:2:4000))
i get the following error:
Error using fread Invalid file identifier. Use fopen to generate a valid file identifier.
how i can read these data?
thank in advance
  1 个评论
Star Strider
Star Strider 2017-1-28
If you are using the PhysioBank ATM to access the files, it is much easier to request the MATLAB ‘.mat’ file than the other formats to use them in MATLAB. Then you can just load them. Be sure to download the accompanying ‘.info’ file as well, since it has the sampling frequency and other information you will need to process your signals

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2017-1-28
fd = fopen( fullfile(pathname, filename), 'r')
  2 个评论
anas qazaz
anas qazaz 2017-1-28
thank Mr Walter my data stored in E drive , bin file, the data file name 102.dat how i can use your code?
Walter Roberson
Walter Roberson 2017-1-28
[filename, pathname] = uigetfile('*.dat', 'Open file .dat');
if isequal(filename, 0) || isequal(pathname, 0)
disp('File input canceled.');
ECG_Data = [];
else
fid = fopen( fullfile(pathname, filename), 'r')
time = 10;
f = fread(fid)
Orig_Sig=f(1:length(f));
plot(Orig_Sig(1:2:4000))
end
You are requesting to open a file that is not in your current directory. uigetfile() returns the directory and filename in different outputs -- so it does know which directory you requested but the directory is not built into the filename output. You then tried to open using just the filename output without putting together the information uigetfile() returned about the directory.

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by