# Why is there an offset in my butterworth and cheby filters when they have the same values?

조회 수: 3(최근 30일)
Clas Hagström 20 May 2020
답변: Star Strider 20 May 2020
Below are the plots and the code for my filters. My assignment is to compare making a bandstop filter with a cheby filter and a butterworth filter, and i know the differences to expect and i don't think one of them is an offset in the x-axis, so what is happening?  clc, clear, close all;
Wn = [2000 2500];
[b,a] = butter(4,Wn,'stop','s');
h = freqs(b,a) ;
Wn = [2000 2500];
[d,e] = cheby1(4,3,Wn,'stop','s');
c = freqs(d,e) ;
mag = mag2db(abs(h));
phase1 = angle(h);
phasedeg1 = phase1*180/pi
subplot(2,1,1), semilogx(mag), grid on
hold on
subplot(2,1,2), semilogx(phasedeg1), grid on
xlabel 'Frequency (rad/s)', ylabel 'Phase (degrees)'
hold on
bag = mag2db(abs(c))
phase2 = angle(c)
phasedeg2 = phase2*180/pi
subplot(2,1,1), semilogx(bag), grid on
hold on
subplot(2,1,2), semilogx(phasedeg2), grid on
xlabel 'Frequency (rad/s)', ylabel 'Phase (degrees)'

### 답변(1개)

Star Strider 20 May 2020
There is not really much difference. It is necessary to get the matching frequency vector (‘wh’ and ‘wc’ here) from the freqs function, then plot the magnitudes and phases as functions of them, respectively:
Wn = [2000 2500];
[b,a] = butter(4,Wn,'stop','s');
[h,wh] = freqs(b,a) ;
Wn = [2000 2500];
[d,e] = cheby1(4,3,Wn,'stop','s');
[c,wc] = freqs(d,e) ;
mag = mag2db(abs(h));
phase1 = angle(h);
phasedeg1 = phase1*180/pi;
subplot(2,1,1), semilogx(wh,mag), grid on
xlim([2000 3000])
hold on
subplot(2,1,2), semilogx(wh,phasedeg1), grid on
xlabel 'Frequency (rad/s)', ylabel 'Phase (degrees)'
xlim([2000 3000])
hold on
bag = mag2db(abs(c));
phase2 = angle(c);
phasedeg2 = phase2*180/pi;
subplot(2,1,1), semilogx(wc,bag), grid on