Clear Filters
Clear Filters

Error in fir1 (line 115) Wind = chkwindow(Wind,L);

10 views (last 30 days)
i'm trying to use low pass FIR filter for EEG siganl that i have downloded from http://physionet.org/physiobank/database/chbmit/ but i got this error message Error using fir1>chkwindow (line 290) The window length must be the same as the filter length.
Error in fir1 (line 115) Wind = chkwindow(Wind,L); my code is: load('C:\Users\del.dell-PC\Downloads\chb01_01_edfm.mat') x = plot(val(1,:)); Fs=200; t = linspace(0,1,Fs); fc = 32; Wn = (2/Fs)*fc; L =40; b = fir1(40,Wn,'low',hamming(L)); fvtool(b,1,'Fs',Fs) y = filter(b,1,x);
plot(t,x,t,y) xlim([0 0.1])
xlabel('Time (s)') ylabel('Amplitude') legend('Original Signal','Filtered Data')
how can i fix that and how can i define the downloded signal thank you

Accepted Answer

Star Strider
Star Strider on 10 Mar 2017
In R2017a (and probably earlier versions), the hamming window is the default. You only need to specify it as:
Fs=200;
t = linspace(0,1,Fs);
fc = 32;
Wn = (2/Fs)*fc;
L =40;
b = fir1(40,Wn);
figure(1)
freqz(b, 1, 2^16, Fs)
I included the freqz call so you can see that it works. It is not necessary for the code, and can be deleted.
Remember to use the filtfilt function to do the actual filtering.
  22 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!