巴特沃夫低通滤波器在MATLAB中怎么实现
%利用脉冲响应不变法,用巴特沃斯原型设计
%技术指标:wp=0.4*pi,ws=0.6*pi,Ap=0.5dB,As=50dB
wp=0.4*pi;
ws=0.6*pi;
Ap=0.5;
As=50;
Fs=1000;T=1/Fs;
omegap=wp*Fs;omegas=ws*Fs;
ripple=sqrt(1/10^(0.1*Ap));
attn=1/(10^(As/20));
[N,omegac]=buttord(omegap,omegas,Ap,As,'s');
[z0,p0,k0]=buttap(N);
k=k0*omegac^N;
z=z0*omegac;p=p0*omegac;
ba=k*real(poly(z));
aa=real(poly(p));
[bd,ad]=impinvar(ba,aa,Fs);
[H,w]=freqz(bd,ad,1000,'whole');
H=[H(1:501)]';
w=[w(1:501)]';
mag=abs(H);
db=20*log10(mag);
pha=angle(H);
figure;
subplot(221);
plot(w/pi,mag);
ylabel('|H|');title('幅度响应');axis([0 1 0 1.1]);
grid;
set(gca,'xtickmode','manual','xtick',[0 0.4 0.6 1]);
set(gca,'ytickmode','manual','ytick',[0 attn ripple 1]);
subplot(222);
plot(w/pi,pha/pi);
xlabel('频率(单位:pi)');ylabel('单位:pi');title('相位响应');
axis([0 1 -1 1]);
grid;
set(gca,'xtickmode','manual','xtick',[0 0.4 0.6 1]);
set(gca,'ytickmode','manual','ytick',[-1 0 1]);
subplot(223);
plot(w/pi,db);
xlabel('频率(单位:pi)');ylabel('分贝');title('幅度(单位:分贝)');
axis([0 1 -150 50]);
grid;
set(gca,'xtickmode','manual','xtick',[0 0.4 0.6 1]);
set(gca,'ytickmode','manual','ytick',[-100 -50 0 50]);
set(gcf,'color','w');
%程序运行结果如下图