How to read a file unrecongnized to Matlab
古いコメントを表示
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
2011 年 6 月 10 日
0 投票
You can use textscan() function to read it. Some other functions are textread(),dlmread(). Try it yourself first.
Walter Roberson
2011 年 6 月 11 日
0 投票
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 件のコメント
Talha
2011 年 6 月 11 日
Walter Roberson
2011 年 6 月 11 日
When you get to the line that has text, textscan() with the '%d' format is not going to be able to read the number and is going to return an empty array.
Talha
2011 年 6 月 11 日
Walter Roberson
2011 年 6 月 11 日
If you know the number of lines of valid data, then you can pass textscan the number of times to repeat the format. For example,
C = textscan(fid, repmat('%d',1,8), 60,'CollectOutput',1);
r = C{1};
Talha
2011 年 6 月 13 日
Fangjun Jiang
2011 年 6 月 13 日
How do you want to deal with those text? Can you simply ignore them and would that impact your numeric data? Post a short set of data with that scenario and we can help you.
Walter Roberson
2011 年 6 月 13 日
fgetl() to read the line, after which you could start another textscan()
Talha
2011 年 6 月 13 日
カテゴリ
ヘルプ センター および File Exchange で Naming Conventions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!