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');
I notice your original code used design(fspec,'IIR') but the error message is for design(fspec,'FIR') ?
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.
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.
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
