%要求设计一butterworth低通数字滤波器,wp=30hz,ws=40hz,rp=0.5,rs=40,fs=100hz。 >>wp=30;ws=40;rp=0.5;rs=40;fs=100; >>wp=30*2*pi;ws=40*2*pi;
>> [n,wn]=buttord(wp,ws,rp,rs,'s'); >> [z,p,k]=buttap(n);
>> [num,den]=zp2tf(z,p,k);
>> [num1,den1]=impinvar(num,den);
Warning: The output is not correct/robust.
Coeffs of B(s)/A(s) are real, but B(z)/A(z) has complex coeffs.
Probable cause is rooting of high-order repeated poles in A(s). > In impinvar at 124
>> [num2,den2]=bilinear(num,den,100); >> [h,w]=freqz(num1,den1); >> [h1,w1]=freqz(num2,den2); >>subplot(1,2,1);
>>plot(w*fs/(2*pi),abs(h)); >>subplot(1,2,2);
>>plot(w1*fs/(2*pi),abs(h1)); >>figure(1);
>>subplot(1,2,1);
>>zplane(num1,den1); >>subplot(1,2,2);
>>zplane(num2,den2);
%要求设计一chebyshev1低通数字滤波器,wp=30hz,ws=40hz,rp=0.5,rs=40,fs=100hz. >>wp=30;ws=40;rp=0.5;rs=40;fs=100; >>wp=30*2*pi;ws=40*2*pi;
>> [n,wn]=cheb1ord(wp,ws,rp,rs,'s'); >> [z,p,k]=cheb1ap(n,rp); >> [num,den]=zp2tf(z,p,k);
[num1,den1]=impinvar(num,den);
>> [num2,den2]=bilinear(num,den,100); [h,w]=freqz(num1,den1); [h1,w1]=freqz(num2,den2); subplot(1,2,1);
plot(w*fs/(2*pi),abs(h)); subplot(1,2,2);
plot(w1*fs/(2*pi),abs(h1)); figure(2);
subplot(1,2,1);
zplane(num1,den1); subplot(1,2,2);
zplane(num2,den2);
%要求设计一chebyshev2低通数字滤波器,wp=30hz,ws=40hz,rp=0.5,rs=40,fs=100hz. wp=30;ws=40;rp=0.5;rs=40;fs=100; wp=30*2*pi;ws=40*2*pi;
[n,wn]=cheb2ord(wp,ws,rp,rs,'s'); [z,p,k]=cheb2ap(n,rs);
[num,den]=zp2tf(z,p,k);
[num1,den1]=impinvar(num,den); [num2,den2]=bilinear(num,den,100); [h,w]=freqz(num1,den1); [h1,w1]=freqz(num2,den2); subplot(1,2,1);
plot(w*fs/(2*pi),abs(h)); subplot(1,2,2);
plot(w1*fs/(2*pi),abs(h1)); figure(2);
subplot(1,2,1);
zplane(num1,den1); subplot(1,2,2);
zplane(num2,den2);
Rp,rs增大,chebyshev2的幅频响应图会好 wp=500;ws=600;rp=1;rs=60;fs=1000; wp=500*2*pi;ws=600*2*pi;