How to calculate passband and stopband coefficients for signal filtering?

106 ビュー (過去 30 日間)
farzad
farzad 2019 年 12 月 24 日
コメント済み: Pallove Nautiyal 2022 年 5 月 18 日
Hi All
using the following code, I need that my passband frequency be 250 Hz , and the Stop Band at 512 Hz. how do I calculate Wp and Ws to insert in the code ?
Ts = 0.001; % Sampling Interval (s)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = 0.001; % Passband Frequency For Lowpass Filter (Hz)
Ws = 0.0012; % Stopband Frequency For Lowpass Filter (Hz)
Rp = 1; % Passband Ripple For Lowpass Filter (dB)
Rs = 50; % Stopband Ripple (Attenuation) For Lowpass Filter (dB)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Calculate Filter Order
[z,p,k] = ellip(n,Rp,Rs,Wp); % Calculate Filter
[sos,g] = zp2sos(z,p,k); % Second-Order-Section For Stability
% A_Filt = filtfilt(sos,g,A); % Filter Signal
figure
freqz(sos, 2^14, Fs) % Filter Bode Plot (Check Performance)
set(subplot(2,1,1), 'Xlim',[0 1])
set(subplot(2,1,2), 'Xlim',[0 1])

採用された回答

Star Strider
Star Strider 2019 年 12 月 24 日
Specifying both passband and stopband frequencies (and without other arguments to the ellip function) means that you are designing a bandpass filter. I appreciate your quoting my code, however I also posted several examples of elliptical filters using bandpass filters.
For your filter, replace ‘Wp’ with:
Wp = [250 512]/Fn; % Passband Frequencies For Bandpass Filter (Hz)
and ‘Ws’ with:
Ws = [0.99 1.01]*Wp; % Stopband Frequencies For Bandpass Filter (Hz)
or define it yourself, similarly to the way I defined ‘Wp’ here. Note that for a bandpass filter, the stopbands must be outside the passbands.
  16 件のコメント
Danish khan
Danish khan 2020 年 5 月 22 日
Can you tell us a way on how to calculate maximum stopband attenuation?
Pallove Nautiyal
Pallove Nautiyal 2022 年 5 月 18 日
please let me know the same @Danish khan if you got to know how to calculate stopband attenuation too.

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

その他の回答 (1 件)

Maria Amr
Maria Amr 2020 年 11 月 3 日
Hello Star Strider,
I have a signal, that is a well log Acoustic Impedance log and I need to apply a Antialias filter in coarser samoling that means a bandpass filter.
Sample frequency is 6562 per kilometer (28000 sample/4.27km). I do need to identify cutt off frequencies correctly. I applied your passband code into my dataset but my proffessors says: apply an anti-alias filter that has a flat spectrum over the band of interest. Would you please direct me how I can identify cutoff frequencies? Appreciated!

カテゴリ

Help Center および File ExchangeFrequency Transformations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by