How to understand the design of lowpass butter filter?
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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.
signal_filtered1 = filtfilt(sos1,g1,signal);
signal_filtered2 = filtfilt(sos2,g2,signal);
That should produce the correct result.
.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Filter Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!