Error using filtfilt.m, 'Input arguments must be 'double''
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I have an EEG .txt data file with 372000 columns and 128 rows, to 4 precision points. I need to load one row at a time and check the spectrum for each channel/row and if it detects > 5dB periodic 50 Hz noise it filters that channel and only that channel. I know I should use notch filter and I have gotten so far (but it does not function):
b1 = fir1(4,[0.4 0.43],'stop');
b2 = fir1(4,[0.01 0.99],'bandpass');
E1 = filtfilt(b1,1,EEG);
E = filtfilt(b2,1,E1);
fspec = fdesign.notch('N,F0,Q,Ap',6,0.1,10,5);
d = design(fspec,'IIR');
Ntchd = filter(d,E1);
採用された回答
Walter Roberson
2016 年 12 月 6 日
Try
E1 = filtfilt(b1, 1, double(EEG) );
9 件のコメント
Emoke Ipkovich
2016 年 12 月 7 日
編集済み: Walter Roberson
2016 年 12 月 7 日
Thank for your reply. I tried double(EEG) before but then I have a different error message:
Error using fdesign.abstracttype/superdesign (line 95)
There are no FIR designs for specification type: 'N,F0,Q,Ap'.
Error in fdesign.abstracttype/design (line 13)
varargout{1} = superdesign(this, varargin{:});
Error in EEG_filter (line 52)
d = design(fspec,'FIR');
Walter Roberson
2016 年 12 月 7 日
I notice your original code used design(fspec,'IIR') but the error message is for design(fspec,'FIR') ?
Emoke Ipkovich
2016 年 12 月 8 日
Well, I changed it in the meanwhile but with none of them works.
@Emoke: When you only claim, that it "does not work", you do not give us any chance to help you. If you need help, please provide any details. Does it not work, because you have plugged out the computer from your wall socket, because you need it for your boiler to make a good calming cup of tea? Why do you simply change the filter from "FIR" to "IIR"? This is not only another name, but a completely different job.
Emoke Ipkovich
2016 年 12 月 8 日
Dear Jan,
You are right, let's shed more light onto the problem. I am having trouble with the following actually:
1) the .txt file contains data (all up to 4 decimal points like 1234.5678) in 128 rows and 372000 columns, separated by tabs. I need to read the data row by row before I apply the filter. I'm having trouble designing this because dlmread did not allow /t to be a delimiter. 2) once the (i)th line is read into variable EEG, I want to apply the filter I have posted in my question. It should check if there is >5db noise between 48 and 52 Hz. If yes, the channel (row) should be filtered. 3) once filtered, I want to save this line to the txt file before moving to the next line (loop from 1 to 128).
Maybe I did not get the first line of data correctly into array EEG and this is why the filter doesn't work. The last error message, after trying many things, was "there are no FIR designs for specification type N,F0,Q,Ap in the fdesign part.
Any help is much appreciated.
Walter Roberson
2016 年 12 月 8 日
dlmread allows '\t' as delimiter. Also if you have R2013b or later, you could use readtable()
I used
EEG = rand(1,1000);
and ran your code that you posted in your Question and did not receive an error. Perhaps you are using an older MATLAB version? What release are you using?
Emoke Ipkovich
2016 年 12 月 8 日
編集済み: Walter Roberson
2016 年 12 月 8 日
Now I tried using textscan to read my data form the .txt file into variable EEG:
fileID = fopen('gtre_001.txt');
for i=1:5
eeg = textscan(fileID,'%.4f',5,'Delimiter','\t');
disp(eeg)
end
fclose(fileID)
This is what I got:
[5×1 double]
[5×1 double]
[5×1 double]
[5×1 double]
[5×1 double]
ans =
0
Please help how to read the .txt file.
ncol = 372000;
fmt = repmat('%f', 1, ncol);
fileID = fopen('gtre_001.txt');
for row = 1 : 128
eeg_cell = textscan(fileID, fmt, 1, 'Delimiter', '\t', 'CollectOutput', 1);
fprintf('Read row %d\n', row);
Process_a_Row(row, eeg_cell{1});
end
fclose(fileID)
Here, Process_a_Row would be the code you want to do for each row, such as the filtering. I pass in the row number in case you want to write each row to an output file using the row number as part of the file name.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で EEG/MEG/ECoG についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
