How to understand the design of lowpass butter filter?

15 ビュー (過去 30 日間)
Kalasagarreddi Kottakota
Kalasagarreddi Kottakota 2023 年 6 月 26 日
回答済み: Star Strider 2023 年 6 月 26 日
Hi, I am designing a low pass butter filter with very small cut-off freqeuncy. But I see very wierd results which I could not understand. Could some one help me regarding this? In the first code fc is 100 Hz and second code it 10 Hz. When 100Hz, I see clearly from 1st plot the cutoff frequency, but when it is 10 Hz, I dont know whats happening, the 2nd plot does not have any initial data.
fc = 100;
fs = 36000;
[b,a] = butter(6,fc/(fs/2));
figure()
freqz(b,a,[],fs)
xlim([0 200])
%%
fc = 10;
fs = 36000;
[b,a] = butter(6,fc/(fs/2));
figure()
freqz(b,a,[],fs)
xlim([0 200])

採用された回答

Star Strider
Star Strider 2023 年 6 月 26 日
It is best not to use the transfer function implementation of discrete (digital) filters, because those are frequently unstable. Use zero-pole-gain and second-order-section implementation instead.
Example —
fc = 100;
fs = 36000;
[z,p,k] = butter(6,fc/(fs/2));
[sos1,g1] = zp2sos(z,p,k);
figure()
freqz(sos1,2^16,fs)
set(subplot(2,1,1),'XLim',[0 200])
set(subplot(2,1,2),'XLim',[0 200])
%%
fc = 10;
fs = 36000;
[z,p,k] = butter(6,fc/(fs/2));
[sos2,g2] = zp2sos(z,p,k);
figure()
freqz(sos2,2^16,fs)
set(subplot(2,1,1),'XLim',[0 200])
set(subplot(2,1,2),'XLim',[0 200])
I also made a few small changes to improve the plots.
Use the filtfilt function to filter the signal using these filters:
signal_filtered1 = filtfilt(sos1,g1,signal);
signal_filtered2 = filtfilt(sos2,g2,signal);
That should produce the correct result.
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by