How to read a file unrecongnized to Matlab

3 ビュー (過去 30 日間)
Talha
Talha 2011 年 6 月 10 日
hi, i am working on implementing the ECG on my DSP kit. i have stored the file using the provided software but its extension is ".ecg". Matlab of course does not read it directly...
If a open it in Matlab directory as OPEN AS TEXT, it opens. Then the data is shown to me as values from 8 channels of ECG. It has 8 numericals values in a spaced single row. And there are around 8000 rows with occasionally english text for heart rate and leads off status.
So is there a way i can read it?? Thanks.

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2011 年 6 月 10 日
You can use textscan() function to read it. Some other functions are textread(),dlmread(). Try it yourself first.
  1 件のコメント
Talha
Talha 2011 年 6 月 11 日
I did what you have suggested. And i got the following results: I used textscan cause that seemed appropriate. Now the textscan make a cell and i would need an array to further plot and separate the data. Also it make the cell only up the first english text appears. So is there a way around or am i using wrong command after all...??

サインインしてコメントする。


Walter Roberson
Walter Roberson 2011 年 6 月 11 日
If you have a mix of numbers and text and the text can appear at any line in the file, then you have to parse the data line by line. See for example the procedure in this Question
  8 件のコメント
Walter Roberson
Walter Roberson 2011 年 6 月 13 日
fgetl() to read the line, after which you could start another textscan()
Talha
Talha 2011 年 6 月 13 日
the data is of the form below. And it would not hurt to store the heart rate. But right now the my main agenda is to read the numerical values. The thing is that the text appears randomly in the data.
-65 -81 53 -42 -32 -45 -88 -49
-79 -84 117 19 19 -3 -53 -35
-39 -52 44 -54 -46 -76 -121 -105
-22 -32 1 -119 -118 -166 -194 -161
HEART_RATE 54
LEAD_OFF_STATUS 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
-4 -12 -38 -148 -114 -172 -199 -174
-39 -52 44 -54 -46 -76 -121 -105

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by