フィルターのクリア

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:')

採用された回答

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 Center および File ExchangeAnalog Filters についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by