There is an error in your code that prevents you from calculating the passbands and stopbands correctly.
This calculation:
gives you these passbands:
However the passbands you want are:
Wp = [1 49]/(Fsp/2);
Wp =
0.002 0.098
Those will give you the correct result. The parentheses around ‘(Fsp/2)’ make all the difference.
If you want to design a filter with rolloffs as steep as you want, a Butterworth filter is not the best option. I would use a Chebyshev Type II design.
The Code —
Fsp = 1000;
Fn = Fsp/2;
Wp = [1.0 49]/Fn;
Ws = [0.5 50]/Fn;
Rp=10;
Rs=30;
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs);
[z,p,k] = cheby2(n,Rs,Ws);
[sos,g] = zp2sos(z,p,k);
figure(1)
freqz(sos, 2^16, Fsp)
set(subplot(2,1,1), 'XLim',[0 100])
set(subplot(2,1,2), 'XLim',[0 100])
The passband ripple in a Chebyshev Type II filter are irrelevant, since the filter has a flat passband. Allowing them to be 10 dB allows you to design a stable filter.
Best Answer