BandPass filter using ellipord

17 ビュー (過去 30 日間)
huskies_0223
huskies_0223 2019 年 7 月 2 日
コメント済み: Star Strider 2019 年 7 月 2 日
How do I use multiple normalized passband frequencies (Wp) and normalized stopband frequencies (Ws) in the ellipord function to create a bandpass filter? I need to create a bandpass filter using the ellipord function given more than one Wp and Ws. I have more than one of these variables because I have to use the the following frequencies to set the stopband (fs) and passbands (fp); fp1 = 700Hz, fp2 = 4.5kHz, fs1 = 300 Hz, and fs2 = 5.5kHz. The following code I tried does not work since I have to many inputs for the ellipord function:
[X Fs] = audioread('song.mp3');
Gp_b = .9
Gs_b = .01
Fp_b1 = 700
Fp_b2 = 4500
Fs_b1 = 300
Fs_b2 = 5500
Wp_b1 = (2*Fp_b1)/Fs
Ws_b1 = (2*Fs_b1)/Fs
Rp_b = -20*log10(Gp_b)
Rs_b = -20*log10(Gs_b)
Wp_b2 = (2*Fp_b2)/Fs
Ws_b2 = (2*Fs_b2)/Fs
[n_b, Wn_b] = ellipord(Wp_b1,Wp_b2,Ws_b1,Ws_b2,Rp_b,Rs_b)
Error using ellipord
Too many input arguments.

採用された回答

Star Strider
Star Strider 2019 年 7 月 2 日
You are close. The passband and stopband frequencies must be stated as two-element vectors, and normalised by the Nyquist frequency. You can state the passband and stopband ripple (attenuation) values directly as dB, the function assumes they are negative and represent attenuations or ripple magnitudes.
The elliptical filter is an excellent choice.
Try this:
% Fs = 44100; % Create A Value To Check Code
Fn = Fs/2; % Nyquist Frequency
Wp = [700 4.5E+3]/Fn; % Normalised Passband Frequencies
Ws = [300 5.5E+3]/Fn; % Normalised Stopband Frequencies
Rp = 1; % Passband Ripple
Rs = 40; % Stopband Ripple (Attenuation)
[n_b,Wn_b] = ellipord(Wp, Ws, Rp, Rs)
[z,p,k] = ellip(n_b, Rp, Rs, Wp); % Use Z,P,K For Precision
[sos, g] = zp2sos(z, p, k); % Use Second-Order Sections For Stability
figure
freqz(sos, 2^14, Fs) % View Filter Bode Plot
X_Filtered = filtfilt(sos, g, X); % Filter Signal
Use the value for ‘Fs’ that your audioread call returns. I used the commented-out value to check my code to be sure it works (no typographical or other errors).
  2 件のコメント
huskies_0223
huskies_0223 2019 年 7 月 2 日
Just tried this out and it works, thank you!
Star Strider
Star Strider 2019 年 7 月 2 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Design についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by