DSP/IIR filter butterworth

9 visualizaciones (últimos 30 días)
Steven
Steven el 16 de Nov. de 2022
Comentada: Steven el 18 de Nov. de 2022
I am just a beginner, I want to design an IIR low-pass filter butterworth. when I use function Butterord and butter, it always has frequency response from 0db. I want the frequency response from 40db. How can I do it ? please help me. Thank you
  2 comentarios
Paul
Paul el 17 de Nov. de 2022
Hi Steven,
I suggest you post your code and results and explain how the desired end result differs from those. I don't know what "response from 40 dB" means, unless it's just
[b,a] = butter(...)
b = 100*b;
Steven
Steven el 17 de Nov. de 2022
Here is my code and my result
fpass = 2500; fstop = 4000; As = 95; Rp=3; fs=44100; %Data
wp=(fpass*2)/fs; ws=(fstop*2)/fs;
[n,Wn] = buttord(wp,ws,Rp,As);
[b,a,k] = butter(n,Wn);
fprintf('\n Bac cua bo loc = %2.0f \n',n)
sos = zp2sos(b,a,k);
freqz(sos,1024,fs)
Ripple of pass-band is 3db and I want to design from 40db instead of from 0db like this. How can i do it ?

Iniciar sesión para comentar.

Respuesta aceptada

Paul
Paul el 17 de Nov. de 2022
Hi Steven,
Here is the original code (with minor changes)
fpass = 2500; fstop = 4000; As = 95; Rp=3; fs=44100; %Data
wp=(fpass*2)/fs; ws=(fstop*2)/fs;
[n,Wn] = buttord(wp,ws,Rp,As);
[z,p,k] = butter(n,Wn);
fprintf('\n Bac cua bo loc = %2.0f \n',n)
Bac cua bo loc = 23
sos = zp2sos(z,p,k);
figure;
freqz(sos,1024,fs);
Here, the phase plot is empty because of the way that freqz computes the phase. Basically, it adds the phase of each sos section. However, if the magnitude at any frequency of a section is less than some threshold, then the phase is set to NaN. The first section in sos is
format short e
sos(1,:)
ans = 1×6
6.7749e-19 6.7749e-19 0 1.0000e+00 -6.9195e-01 0
Those small elements cause the magitude at all frequencies to be below the threshold, so we get NaN for all frequencies and blank plot for the phase.
However, iwe can compute it ourselves (trusting the computation for the small amplitudes at high frequencies)
[h1,f1] = freqz(sos,1024,fs);
figure;
subplot(211)
plot(f1,20*log10(abs(h1)));
xline(fpass);
xline(fstop);
yline(-3);
yline(-95);
subplot(212);
plot(f1,180/pi*angle(h1))
Zoom in at the stop band, achieved 95 dB attenuation
figure;
plot(f1,20*log10(abs(h1)));
xline(fstop);
yline(-95);
xlim([fstop-5 fstop+5])
Zoom in at the pass band, almost achieved 3 dB of attenuation
figure;
plot(f1,20*log10(abs(h1)));
xline(fpass);
yline(-3);
xlim([fpass-5 fpass+5])
Still not sure what you mean by " design from 40db instead of from 0db." Maybe you want to lift the whole gain curve up by 40 db? This will mainting the As and Rp specicifiations relative to 40 dB.
sos = zp2sos(z,p,k*100);
[h1,f1] = freqz(sos,1024,fs);
figure;
subplot(211)
plot(f1,20*log10(abs(h1)));
xline(fpass);
xline(fstop);
yline(-3);
yline(-95);
subplot(212);
plot(f1,180/pi*angle(h1))
If you want the low frequency gain to be 40 dB, but have the Rp and As specifications still be relative to 0 dB, then, in theory, subtract 40 dB from the specifications, design for those specications, then multiply k by 100.
  1 comentario
Steven
Steven el 18 de Nov. de 2022
I think I found what i want in your answer. I just want to lift the whole gain curve up by 40 db. Thank you very much.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Single-Rate Filters en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by