IIR butter filter is not stable

5 visualizaciones (últimos 30 días)
Alex sinWave
Alex sinWave el 29 de Mayo de 2022
Comentada: Star Strider el 30 de Mayo de 2022
Hi,
I am trying to make an IIR filter to a sound wave using butter(); , but the output worked in the first time I started the code then never run correctly after.
I have searched and found that makeing IIR using buttur(); sometimes gives unstable outpot and to overcome this problem I have to use z p k way ([z,p,k] = butter()) but I really do not know how to apply them to my sound signal if anyone can help m I will be thankful.
here is the part of the filters that is not working correctly in my code
[X,Fs] = audioread(filename);
temp = Fs/2;
[num2 , denum2] = butter(50, 170/temp, 'low');
y2 = filter(num2, denum2, X);
[num3 , denum3] = butter(50,[171 310]/temp, 'bandpass');
y3 = filter(num3, denum3, X);
[num4 , denum4] = butter(50,[311 600]/temp, 'bandpass');
y4 = filter(num4, denum4, X);
[num5 , denum5] = butter(50,[601 1000]/temp, 'bandpass');

Respuesta aceptada

Star Strider
Star Strider el 30 de Mayo de 2022
Use second-order-section representation for stability and filtfilt to do the actual filtering —
[X,Fs] = audioread(filename);
temp = Fs/2;
[z2,p2,k2] = butter(50, 170/temp, 'low');
[sos2,g2] = zp2sos(z2,p2,k2);
y2 = filtfilt(sos2,g2, X);
[z3,p3,k3] = butter(50,[171 310]/temp, 'bandpass');
[sos3,g3] = zp2sos(z3,p3,k3);
y3 = filtfilt(sos3,g3, X);
[z4,p4,k4] = butter(50,[311 600]/temp, 'bandpass');
[sos4,g4] = zp2sos(z4,p4,k4);
y4 = filtfilt(sos4,g4, X);
[z5,p5,k5] = butter(50,[601 1000]/temp, 'bandpass');
[sos4,g4] = zp2sos(z5,p5,k5);
y5 = filtfilt(sos5,g5, X);
.
  2 comentarios
Alex sinWave
Alex sinWave el 30 de Mayo de 2022
thank you very much I really appreciate your help.
It worked fine but is there is a way to get the best order I am using 50 randomly and it works fine but for my knowledge curiosity I just want to know if there is a way
Star Strider
Star Strider el 30 de Mayo de 2022
As always, my pleasure!
Yes. Use the buttord function.
Depending on what you want to do, elliptic filters might be a better option, since they are computationally more efficient. For those, begin with ellipord and then ellip. The rest of the steps and the filtering are essentially the same as for the Butterworth filters here.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by