Low-pass filter at 200Hz with a 2khz sampling rate?

5 Ansichten (letzte 30 Tage)
Greydon Gilmore
Greydon Gilmore am 26 Jan. 2017
Kommentiert: Star Strider am 26 Jan. 2017
Hi there,
I have ECoG data and need to only look at frequencies from 1-200Hz. I would like to use a band-pass filter to achieve this but I am having a hard time understanding how to calculate the coefficients and the number of taps. I would like to use a least-squares linear phase FIR filter design. I sampled a 2khz.
  1 Kommentar
Greydon Gilmore
Greydon Gilmore am 26 Jan. 2017
This text file has multiple channels, I would only need one channel to be filtered, in this instance I would like channel #7. In the textfile it is the 10th column.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 26 Jan. 2017
Your design seems unnecessarily complicated to me.
I would use something like this:
Fs = 44100; % Sampling frequency
fcuts = [10 20 20E+3 21E+3]; % Frequency Vector (Hz)
mags = [0 1 0]; % Magnitude (Defines Passbands & Stopbands)
devs = [0.05 0.01 0.05]; % Allowable Deviations
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^14, Fs)
Use the correct sampling frequency (as ‘Fs’) and bandstop and bandpass frequencies (in ‘fcuts’) for your signal.
See the documentation for kaiserord for details. The kaiserord function provides the normalised frequencies for the fir1 function.
  3 Kommentare
John BG
John BG am 26 Jan. 2017
Bearbeitet: John BG am 26 Jan. 2017
To Greydon;
1.
try Low pass filter, not BPF
2.
could you supply a sample of the sampled signal in a file attached to your question?
To Star Strider;
may be you would like to consider changing Fs to 2kHz, oversampling without having access to the original signal may distort rather than increase accuracy.
Star Strider
Star Strider am 26 Jan. 2017
@Greydon Gilmore —
I didn’t see ‘Example File.txt’ earlier.
See if this does what you want:
fidi = fopen('Example File.txt','rt');
D = textscan(fidi, ['%*s%s' repmat('%f',1,11) '%*s'], 'CollectOutput',1);
t = datenum(D{1}, 'HH:MM:SS.FFF');
t = (t-t(1))*24*60*60; % Time Vector (sec)
Ts = mean(diff(t)); % Sampling Time (sec)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
DesiredChannel = 8; % This Should Be Channel #7
s = D{2}(:,DesiredChannel);
fcuts = [0.2 1.5 195 205]; % Frequency Vector (Hz)
mags = [0 1 0]; % Magnitude (Defines Passbands & Stopbands)
devs = [0.05 0.01 0.05]; % Allowable Deviations
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^14, Fs)
sfilt = filtfilt(hh, 1, s); % Filter Signal
figure(2)
subplot(2,1,1)
plot(t, s)
grid
title('Raw Signal')
subplot(2,1,2)
plot(t, sfilt)
grid
title('Filtered Signal')
The filter (passband depicted in figure(1)) appears to do what you want. I don’t see much difference in the filtered signal, other than the elimination of the d-c component, but the filter appears to work correctly.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by