Using freqs to plot butterworth filter frequency response

I'm attempting to use the Matlab freqs function to plot the frequency response of a first and second order butterworth filter by passing it the corresponding A(s) and B(s) polynomial values for each filter order.
I am having a tough time understanding what is showing up when I plot the magnitude vs frequency. It looks like the chart is mirrored, not like a normal butterworth response should look like, and I can't chase down the cause. Anyone have this issue before?
https://imgur.com/a/AuV5d
Code
%First Order
Num1=[0 1];
Dem1=[1 1];
w = (0 : 100*2*pi/100 : 100*2*pi); %freq range
T1=freqs(Num1, Dem1, w); %calculate the transfer function
axis([0 100 -30 0])
plot(w/(2*pi),20*log10(abs(T1)))
%Second Order
Num2=[0 0 1];
Dem2=[1 1.4142 1]; %repeat for second order
T2=freqs(Num2, Dem2, w);
hold on
plot(w/(2*pi), 20*log10(abs(T2)))
grid on
hold off

답변 (1개)

Star Strider
Star Strider 2018년 3월 31일
I don’t understand what you mean by ‘mirrored’.
When I used:
w = logspace(-3, 2);
and used semilogx instead of plot, I got what appears to be an acceptable plot for a lowpass filter. The rest of your code is unchanged.

카테고리

제품

태그

질문:

2018년 3월 31일

답변:

2018년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by