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
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:
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 Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!