Hi Steven,
Here is the original code (with minor changes)
fpass = 2500; fstop = 4000; As = 95; Rp=3; fs=44100;
wp=(fpass*2)/fs; ws=(fstop*2)/fs;
[n,Wn] = buttord(wp,ws,Rp,As);
fprintf('\n Bac cua bo loc = %2.0f \n',n)
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
sos(1,:)
ans =
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);
plot(f1,20*log10(abs(h1)));
plot(f1,180/pi*angle(h1))
Zoom in at the stop band, achieved 95 dB attenuation
plot(f1,20*log10(abs(h1)));
Zoom in at the pass band, almost achieved 3 dB of attenuation
plot(f1,20*log10(abs(h1)));
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.
[h1,f1] = freqz(sos,1024,fs);
plot(f1,20*log10(abs(h1)));
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.