![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/554447/image.png)
Stopband filter with multiple stopbands
6 次查看(过去 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
0 个评论
采纳的回答
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/554447/image.png)
Make appropriate changes for your signal and requirements.
3 个评论
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!