Comparing Analog Butterworth vs Bessel Filters shows large differences in coefficients and filtered data.

조회 수: 16 (최근 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:')

채택된 답변

Paul
Paul 2024년 1월 18일
Hi Xavier,
For "an analog Butterworth" filter, the code would be (butter)
% 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
Xavier Quinn
Xavier Quinn 2024년 1월 18일
Sorry, found the bilinear function. Thanks again for the explaination above.
Paul
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 CenterFile Exchange에서 Analog Filters에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by