How to understand the design of lowpass butter filter?
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kalasagarreddi Kottakota
il 26 Giu 2023
Risposto: Star Strider
il 26 Giu 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])
0 Commenti
Risposta accettata
Star Strider
il 26 Giu 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.
signal_filtered1 = filtfilt(sos1,g1,signal);
signal_filtered2 = filtfilt(sos2,g2,signal);
That should produce the correct result.
.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Digital Filter Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!