Stopband filter with multiple stopbands

15 次查看(过去 30 天)
Hello, I have a fMRI signal sampled at 10 Hz and I need to create a stopband filter with three stop bands
This examle looks something like it but I dont quite understand it:
https://www.mathworks.com/matlabcentral/answers/503999-filtering-for-multiple-band-of-frequncies

采纳的回答

Star Strider
Star Strider 2021-3-18
This is a relatively straightforward problem.
Example —
Fs = 250;
fcomb = [[49 49.5 50.5 51], [49 49.5 50.5 51]+10, [49 49.5 50.5 51]+12.5];
mags = [[1 0 1], [0 1], [0 1]];
dev = [[0.5 0.1 0.5], [0.1 0.5], [0.1 0.5]];
[n,Wn,beta,ftype] = kaiserord(fcomb,mags,dev,Fs);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');
figure
freqz(hh, 1, 2^20, Fs)
set(subplot(2,1,1), 'XLim',[45 65]) % Optional
set(subplot(2,1,2), 'XLim',[45 65]) % Optional
producing:
Make appropriate changes for your signal and requirements.
  3 个评论
Star Strider
Star Strider 2021-3-22
Why is it not just [49 51]?
Because the frequencies on either side of the stopband need to be specified. In this baandstop filter, the first and last elements of the 4-element vector are the passband frequencies, and the centre two are the stopband freqencies. I group the pasband and stopband frequencies together in individual sub-vectors because it’s easier to read and understand the filter construction this way. (The ‘mags’ and ‘devs’ vectors would have reversed magnitudes to design passbands instead of stopbands. This can get complicated quickly, so I’ll stop with that observation. See the relevant documentation for details.)
How do I modify this filter for that since the values of the vectors of fcomb are separated by 0.5 Hz?
This should do what you want:
Fs = 250;
fcomb = [[0.005 0.01 0.1 0.105], [0.115 0.12 0.35 0.38], [0.75 0.8 1.3 1.35]];
mags = [[1 0 1], [0 1], [0 1]];
dev = [[0.5 0.1 0.5], [0.1 0.5], [0.1 0.5]];
[n,Wn,beta,ftype] = kaiserord(fcomb,mags,dev,Fs);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');
figure
freqz(hh, 1, 2^20, Fs)
set(subplot(2,1,1), 'XLim',[0 1.5]) % Optional
set(subplot(2,1,2), 'XLim',[0 1.5]) % Optional
Note that this is going to be a long filter (the length is a funciton of the sampling frequency, acttually), so likely not very efficient. (The sampling frequency should be at least 5 Hz for this filter to work optimally, and above 2.75 Hz for it to work at all.) However if it is only necessary to filter each signal once, the computational efficiency should not be a significant problem. Use the filtfilt function to do the actual filtering.
Pseudoscientist
Pseudoscientist 2022-1-26
How can I edit this filter to be viable for shorter data sets?
MY current dataset is 2960 in temporal dimension but this filter needs it to be atleast 5040

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Filter Design 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by