Difference in the output of butterworth and chebyshev fitlers

4 views (last 30 days)
Hello,
I have used two filters for the atatched signal data 1)butterworth from here and 2)chebyshev using the below codes
clc;
clear all;
%----------------butterworht filter------------------%
filtered1 = bandstop_butterworth(output2,[.2 .35],100,2);
finalsignal = bandstop_butterworth(filtered1,[.5 4],100,2);
%--------------Freq spectrum----------------%
Fs=100;
T=1/Fs;
L=length(finalsignal);
t=(0:L-1)*T;
NFFT=2^nextpow2(L);
Y=fft(finalsignal,NFFT)/L;
f=Fs/2*linspace(0,1,NFFT/2+1);
figure(2),subplot(2,1,1),plot(f,2*abs(Y(1:NFFT/2+1)));hold on;
title('Output of butterworth filters');
xlabel('Frequency');
ylabel('amplitude');
%----------------chebyshev filter---------%
Fs=100;
Fn=Fs/2;
Ws1=[0.2 0.35]/Fn;
n1=2;
R=20;
[b1,a1]=cheby2(n1,R,Ws1,'stop');
[sos1,g1]=tf2sos(b1,a1);
Ws2=[0.5 4]/Fn;
n2=2;
[b2,a2]=cheby2(n2,R,Ws2,'stop');
[sos2,g2]=tf2sos(b2,a2);
YF1=filtfilt(sos1,g1,output2);
YF2=filtfilt(sos2,g2,YF1);
%----------Freq spectrum------------------%
Fs=100;
T=1/Fs;
L=length(YF2);
t=(0:L-1)*T;
NFFT=2^nextpow2(L);
Y=fft(YF2,NFFT)/L;
f=Fs/2*linspace(0,1,NFFT/2+1);
figure(2),subplot(2,1,2),plot(f,2*abs(Y(1:NFFT/2+1)),'-r');
title('Output of chebyshev filters');
xlabel('Frequency');
ylabel('amplitude');
%--------------------------------------%
I wonder why the otuptu of fitlers has different frequenc spectrum(figure attached).
Can someone explain the reason behind the difference between the spectrum of two filters adn which is the best to use.
Thanks.

Answers (1)

Honglei Chen
Honglei Chen on 8 Aug 2014
Are you trying to compare Chebyshev and Butterworth filter? if so, the following URL could be helpful.
HTH

Products

Community Treasure Hunt

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

Start Hunting!