Comparing Analog Butterworth vs Bessel Filters shows large differences in coefficients and filtered data.
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to compare filtered data after passing through an analog Butterworth or Bessel filter. I am using a 3rd order, 100Hz cutoff frequency filter on data which has a sample rate of 20,000 Hz. The coeffiecients are wildly different, as well as the mag/phase plots. I feel like I am missing some normalization factor or a simple mistake like that.
My code is:
% All frequency values are in Hz.
Fs = 20000; % Sampling Frequency
N = 2; % Order
Fc = 100; % Cutoff Frequency
dx = 0.05/1000; % Inverse of sample rate [sec]
[b,a] = butter(N,1/(Fs/Fc),"low");
yf1 = filtfilt(b,a,y);
[bf,af] = besself(N,2*pi*Fc,"low");
yf2 = filter(bf,af,y);
figure;
[h,w] = freqs(b,a);
[hf,wf] = freqs(bf,af);
plot(w,abs(h),'b-',wf,abs(hf),'r:')
0 commentaires
Réponse acceptée
Paul
le 18 Jan 2024
Hi Xavier,
% All frequency values are in Hz.
Fs = 20000; % Sampling Frequency
N = 2; % Order
Fc = 100; % Cutoff Frequency
dx = 0.05/1000; % Inverse of sample rate [sec]
%[b,a] = butter(N,1/(Fs/Fc),"low");
[b,a] = butter(N,2*pi*Fc,'low','s');
% y is not defined, and filtfilt can't be used with an analog filter
%yf1 = filtfilt(b,a,y);
[bf,af] = besself(N,2*pi*Fc,"low");
%yf2 = filter(bf,af,y);
figure;
[h,w] = freqs(b,a);
[hf,wf] = freqs(bf,af);
% plot in dB on semilog scale vs Hz
%plot(w,abs(h),'b-',wf,abs(hf),'r:')
semilogx(w/2/pi,db(abs(h)),'b-',wf/2/pi,db(abs(hf)),'r:')
3 commentaires
Paul
le 18 Jan 2024
Is it possible? Yes.
It is advisable? Maybe. That really depends on why a Bessel filter was selected as the prototype for your particular application and if its discrete-time approximation retains the characteristics that meet the requirements of the problem. Search around on this forum and you'll find some discussion on this very topic across multiple threads.
If you're going to explore this path, in addition to bilinear, you should also look at impinvar for converting the analog Bessel filter to a discrete-time approximation. If you have the Control System Toolbox, check out c2d, which offers additional conversion methods. Each method will result result in a different discrete-time filter that will have different characteristics, particularly as the frequency of the input gets closer to the Nyquist frequency. Hopefully one of those discrete-time filters will be sufficient for your needs.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Analog Filters dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!