DSP/IIR filter butterworth

9 次查看(过去 30 天)
Steven
Steven 2022-11-16
评论: Steven 2022-11-18
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 个评论
Paul
Paul 2022-11-17
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 2022-11-17
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 ?

请先登录,再进行评论。

采纳的回答

Paul
Paul 2022-11-17
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 个评论
Steven
Steven 2022-11-18
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Single-Rate Filters 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by