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

조회 수: 12 (최근 30일)
Clas Hagström
Clas Hagström 2020년 4월 21일
댓글: Star Strider 2020년 4월 21일
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