Comparing Analog Butterworth vs Bessel Filters shows large differences in coefficients and filtered data.
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Paul
2024-1-18
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 个评论
Paul
2024-1-18
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analog Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!