Effacer les filtres
Effacer les filtres

How to understand the design of lowpass butter filter?

11 vues (au cours des 30 derniers jours)
Kalasagarreddi Kottakota
Kalasagarreddi Kottakota le 26 Juin 2023
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])

Réponse acceptée

Star Strider
Star Strider le 26 Juin 2023
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.
.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by