How do i plot the amplitude and phase function of a butterworth filter?

5 次查看(过去 30 天)
I'm want to make a lowest order possible butterworth, chebychev and elliptic filter with the following qualities:
Maximum ripple in passband 3 dB
−3 dB cut-off frequency at 1000 rad/s.
A minimum of 40 dB attenuation in the stop-band for all frequencies above 2000 rad/s
This is how i made my butterworth filter:
clc, clear, close all;
Wp=1000; Ws=2000
[N, Wn] = buttord(Wp, Ws, 3, 40, 's')
[z,p,k] = butter(N,Wn,'s');
[num,den]=zp2tf(z,p,k);
SOS = zp2sos(z,p,k);
freqz(SOS);
now i want to check if it seems correct by plotting the amplitude and phase function but i can only find instructions on how to plot the magnitude and phase functions. Would be very grateful if someone could help.

回答(1 个)

Star Strider
Star Strider 2020-4-21
It is not at all obvious what you are asking.
If you want to plot all filter Bode plots on the same axes, the freqz function can produce outputs if you request them (see the documentation). You can then plot all the amplitudes and phases together in the same sets of axes. Use the subplot function to plot them in the same figure.
  3 个评论
Clas Hagström
Clas Hagström 2020-4-21
Solved it, got thrown of by "help butter" saying i should use: SOS = zp2sos(z,p,k);
freqz(SOS);
Using this got what i wanted:
[num,den]=zp2tf(z,p,k);
freqs(num,den) ;
Star Strider
Star Strider 2020-4-21
It ius always advisable to use:
[z,p,k] butter(N,Wn);
[sos,g] = sp2sos(z,p,k);
Do not use:
[z,p,k] butter(N,Wn,'s');
because that designs a continuous-time filter, not a discrete filter. Continuous-time filters will not work with filtfilt and the other discrete functions, such as freqz, and produce the desired result. It will be necessary to use the blinear function to convert the continuous filter function to a discrete representation. It is easier to design a discrete filter from the outset.

请先登录,再进行评论。

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by