Need help designing stopband filter

4 ビュー (過去 30 日間)
Pseudoscientist
Pseudoscientist 2022 年 1 月 26 日
コメント済み: Star Strider 2022 年 2 月 9 日
Hello,
I'm trying to design a stopband filter that can remove spikes at 1.294 Hz and 3.101 Hz
My data matrix 64x64x64x2960, where the three first dimensions are spatial dimensions and the 4th dimension is the temporal dimension along which I need to filter the data.
I have tried this, but it doesnt work for 2960 data points and requires at least 5040 data points:
Fs = 10;
fcomb = [[1.285 1.29 1.3 1.35],[2.85 2.90 3.15 3.20]];
mags = [[1 0 1], [0 1];
dev = [[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])
I have also tried matlabs bandstop() function, but somehow it made my data completely flat in freq domain. I only want to remove the spikes at 1.294 Hz and 3.101 Hz ...

採用された回答

Star Strider
Star Strider 2022 年 1 月 26 日
Thank you for quoting my code!
The FIR filter will eliminate both frequencies in one filtfilt call to it, however they are not efficient and can only be used on long signals. It might be best to use two IIR filters in series.
That design would be something like this —
Fs = 10;
Fn = Fs/2;
Ws = [1.290 1.298]/Fn;
Wp = Ws.*[0.999 1.001];
Rs = 50;
Rp = 1;
[n,Wn] = ellipord(Wp,Ws,Rp,Rs);
[z,p,k] = ellip(n,Rp,Rs,Wp,'stop');
[sos,g] = zp2sos(z,p,k);
figure
freqz(sos, 2^16, Fs)
set(subplot(2,1,1), 'XLim',[1.25 1.35])
set(subplot(2,1,2), 'XLim',[1.25 1.35])
Ws = [3.0 3.2]/Fn;
Wp = Ws.*[0.999 1.001];
Rs = 50;
Rp = 1;
[n,Wn] = ellipord(Wp,Ws,Rp,Rs);
[z,p,k] = ellip(n,Rp,Rs,Wp,'stop');
[sos,g] = zp2sos(z,p,k);
figure
freqz(sos, 2^16, Fs)
set(subplot(2,1,1), 'XLim',[2.5 3.5])
set(subplot(2,1,2), 'XLim',[2.5 3.5])
There is no way of cascading them functionally, so the only option is to use the output of the first filter as the input to the second filter. Use the filtfilt function to use them to filter the signals.
.
  14 件のコメント
Pseudoscientist
Pseudoscientist 2022 年 2 月 9 日
The virus left my cognitive abilities slightly lowered; this may result in me having to post more questions here. Haha.
Star Strider
Star Strider 2022 年 2 月 9 日
Noi worries about the questions!
Otherwise, I well know that feeling! SARS-CoV-2 precipitates a sustained immune response with elevated cytokines and interleukins of several varieties. That’s likely the cause of the ‘brain fog’, and it takes a while to get back to normal.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by