How do i plot the amplitude and phase function of a butterworth filter?
5 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Star Strider
on 21 Apr 2020
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 Comments
Star Strider
on 21 Apr 2020
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!