필터 지우기
필터 지우기

Need help designing stopband filter

조회 수: 2 (최근 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 CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by