Different frequency responses using [z,p,k] method and [b,a] for 2nd order elliptical filter

5 ビュー (過去 30 日間)
Hi, I am designing an elliptical filter and using 2nd order. My code is below, however, both of them display different frequency responses. Why is that so? Am I doing something wrong here? However, when I am plotting for 4th order, both responses are same.
%Filter design
[b,a]=ellip(2,20,25,200/210,'high');
% [b,a]=ellip(2,20,25,[2000 9000]/(fs/2),'bandpass');
fvtool(b,a)
[z,p,k] = ellip(2,20,25,200/210,'high');
sos = zp2sos(z,p,k);
fvtool(sos)

採用された回答

Star Strider
Star Strider 2021 年 7 月 19 日
You are doing everything correctly, however you only need to use the second-order-section (‘sos’) representation, since it essentially guarantees an efficient, stable filter. Transfer-function implementations can produce unstable or unreliable results.
What may be confusing the issue however are the arguments to the ellip function. This designs a second-order filter with a passband attenuation of 20 dB and a stopband attenuation of 25 dB. It may be worth reconsidering those values in order to get a usable filter. I suggest that you start with the ellipord function, and go from there.
Fs = 420;
[z,p,k] = ellip(2,20,25,200/210,'high');
[sos,g] = zp2sos(z,p,k);
figure
freqz(sos, 2^16, Fs)
.
  10 件のコメント
Giggs B.
Giggs B. 2021 年 8 月 2 日
I see, thank you.
Star Strider
Star Strider 2021 年 8 月 2 日
As always, my pleasure!
.

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

その他の回答 (1 件)

Paul
Paul 2021 年 7 月 19 日
編集済み: Paul 2021 年 7 月 19 日
If fvtool is like freqz, you need to make sure that the sos input has more than one row. Otherwise, the input might not be interpreted as an sos input. Here's an example with freqz.
[b,a]=ellip(2,20,25,200/210,'high');
[z,p,k] = ellip(2,20,25,200/210,'high');
[sos,g] = zp2sos(z,p,k);
freqz(b,a)
freqz(sos)
freqz([sos;[g 0 0 1 0 0]]) % add another section that is gain g for the expected response
  3 件のコメント
Paul
Paul 2021 年 7 月 20 日
Each second order section is of the form [b a], so an sos array for n sections is n x 6 is of the form:
[b1 a1;
[b2 a2;
.
.
.
bn an]
So that second section represents
b2 = [g 0 0]
a2 = [1 0 0]
which is just a gain of g. As I showed (and stated in doc freqz) if you want to use sos as input to freqz, it has to have at least two sections. So I added a second section that is effectively a unity gain of g to a) make freqz realize the input is sos, and b) to make the gain of the product of those sos's match the gain of the filter.
Giggs B.
Giggs B. 2021 年 7 月 20 日
Okay, got it. Thank you.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by