此处是MATLAB 的代码
wp=2*pi*5000;ws=2*pi*12000;Rp=2;Rs=30;
[N,wc]=buttord(wp,ws,Rp,Rs,'s');% s is the anology filter
[B,A]=butter(N,wc,'s');
sk=0:511; fk=0:14000/512:14000;wk=2*pi*fk;
Hk=freqs(B,A,wk);
plot(fk/1000,20*log10(abs(Hk)),'r') ;hold on
xlabel('频率(khz)');ylabel('幅度(db)');
axis([0,14,-40,5]);
[N,wc]=buttord(wp,ws,10,Rs,'s');% s is the anology filter
[B,A]=butter(N,wc,'s');
Hk=freqs(B,A,wk);
plot(fk/1000,20*log10(abs(Hk)),'g');
[N,wc]=buttord(wp,ws,20,Rs,'s');% s is the anology filter
[B,A]=butter(N,wc,'s');
Hk=freqs(B,A,wk);
plot(fk/1000,20*log10(abs(Hk)),'b');
legend('Rp=2','Rp=10','Rp=20','Location','northeast','Orientation','horizontal')
运行结果: 分析,Rp 越大,通达的振幅越大
参考“: