DSP/IIR filter butterworth
9 views (last 30 days)
Show older comments
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 Comments
Paul
on 17 Nov 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;
Accepted Answer
Paul
on 17 Nov 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)
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,:)
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.
More Answers (0)
See Also
Categories
Find more on Single-Rate Filters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!