iir filter saturation problems

4 次查看(过去 30 天)
nxp nxp
nxp nxp 2022-9-21
评论: Chunru 2022-9-21
I want to implement IIR filter without MATLAB functions. I get the coefficients as follows (Fs = 1000 , BPF 5-15Hz)
f1=5;
f2=15;
Wn=[f1 f2]*2/fs;
N = 3;
[b,a] = butter(N,Wn);
b = flipud(b')
a = -flipud(a')
b coff:
1.0e-04 *
-0.2915
0
0.8744
0
-0.8744
0
0.2915
a coff:
-0.8819
5.3942
-13.7568
18.7244
-14.3455
5.8657
-1.0000
And I have written the filter code as below, but the output goes to infinity.
for i = 7 : N
BPF(i) = 0.0001*(-0.2915*X(i) +0.8744* X(i-2) - 0.8744* X(i-4) + 0.2915* X(i-6))...
+(-0.8819*BPF(i-1)+5.3942*BPF(i-2)-13.7568* BPF(i-3)+18.7244*BPF(i-4)-14.3455*BPF(i-5)+5.8657*BPF(i-6));
end

回答(1 个)

Chunru
Chunru 2022-9-21
It seems that your implementation of filter is not correct and hencie make the iir filter not stable:
for i = 7 : N
BPF(i) = 0.0001*(-0.2915*X(i) +0.8744* X(i-2) - 0.8744* X(i-4) + 0.2915* X(i-6))...
+(-0.8819*BPF(i-1)+5.3942*BPF(i-2)-13.7568* BPF(i-3)+18.7244*BPF(i-4)-14.3455*BPF(i-5)+5.8657*BPF(i-6));
end
Replace above with
BPF = filter(b, a, X)
  2 个评论
nxp nxp
nxp nxp 2022-9-21
its right.But why it is not stable? for initial value of output? I want to implement it with C
Chunru
Chunru 2022-9-21
For iir filter, the poles of transfer function must be within unit circle to be stable.
Your filter formula is implemting a different filter from "filter(b, a, x)" and it somehow not stable. Check out your implementation according the the IIR filter formula.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by