本文用双线性变换法设计原型低通为椭圆型的数字IIR高通滤波器,通带边界频率为550Hz,阻带边界频率分别为450Hz,通带最大衰减3dB,阻带最小衰减42dB,抽样频率为2000Hz,并用MATLAB画出了其幅频特性,滤波器传输函数的零极点及滤波器规范性结构图。
用MATLLAB生成正弦连续信号:
,使它经过该滤波器,其中 , , ,观察滤波器的输出,并用MATLAB 给出 , , , , 的图形。
通过本次滤波器设计掌握用双线性变换法设计原型低通为椭圆型的数字IIR高通滤波器的原理和设计方法;求出所设计滤波器的Z变换;用MATLAB画出幅频特性图;并分别用CONV命令及自编卷积函数验证所设计的滤波器。
clc;
clear;
Rp=3;%通带最大衰减3db
Rs=42;%阻带最小衰减42db
Fs=2000;%抽样频率
OmegaP1_1=550;%通带边界频率
OmegaS1_1=450;%阻带边界频率
Wp1=2*pi*OmegaP1_1/Fs;%将模拟频率转换为数字角频率
Ws1=2*pi*OmegaS1_1/Fs;
OmegaP1=tan(Wp1/2);%非线性变换
OmegaS1=tan(Ws1/2);
Eta_P=OmegaP1/OmegaP1;%归一化
Eta_S=OmegaS1/OmegaP1;
Lemta_P_EquivLowPass=1/Eta_P;%转换为等效低通参数
Lemta_S_EquivLowPass=1/Eta_S;
%估计椭圆模拟低通滤波器的阶数
[N,Wn]=ellipord(Lemta_P_EquivLowPass,Lemta_S_EquivLowPass,Rp,Rs,'s');
%N为实现性能的最小阶数,Wn为模拟滤波器的截止频率
%设计滤波器
[num1,den1]=ellip(N,Rp,Rs,Wn,'s');
[num2,den2]=lp2hp(num1,den1,OmegaP1);
[num,den]=bilinear(num2,den2,0.5);
%计算增益响应
w=0:pi/255:pi;
h=freqz(num,den,w);
g=20*log10(abs(h));
%画出增益响应
figure;
plot(w/pi,g);grid
axis([0 1 -60 5]);
xlabel('\omega/\pi');ylabel('Gain in dB');
title('Gain response of a elliptic highpass filter');
%画零点极点图
figure;
[z,p,k]=tf2zp(num,den);
zplane(z,p);
title('Zero and pole point');
%------------------------%------------------------%
%输入信号x(t),输出y(t)
Coeff_lf=1;%低频信号系数
Coeff_mf=1;%中频信号系数
Coeff_hf=1;%高频信号系数
F1=250;%低频信号频率
F2=350;%中频信号频率
F3=650;%高频信号频率
%时域
Endtime=1/Fs*1023;
Time=0:1/Fs:Endtime;
N=length(Time);
%生成正弦信号x1(t),x2(t),x3(t),x(t)
Signal_x1=Coeff_lf*sin(2*pi*F1*Time); % x1(t)
Signal_x2=Coeff_mf*sin(2*pi*F2*Time); % x2(t)
Signal_x3=Coeff_hf*sin(2*pi*F3*Time); % x3(t)
Signalsum_x=Signal_x1+Signal_x2+Signal_x3;%x(t)
Signal_x=Signalsum_x;
%画出信号x1(t)
figure
subplot(2,1,1);
plot(Time,Signal_x1);
xlabel('Time');
xlim([0 0.05])
title('时域信号 x1(t)');
FFTSignal_x1=2/N*fft(Signal_x1);
subplot(2,1,2)
Fnsin_x1=abs(FFTSignal_x1);
FW=2*pi*Time/Endtime;
plot(FW(2:length(FW))*Fs/pi/2,Fnsin_x1(2:length(FW)));
hold on
plot((FW(2:length(FW))-2*pi)*Fs/pi/2,Fnsin_x1(2:length(FW)));
xlim([-Fs/2 Fs/2]);
xlabel('Frequence');
%绘制x2(t)
figure
subplot(2,1,1);
plot(Time,Signal_x2);
xlabel('Time');
xlim([0 0.05])
title('时域信号 x2(t)');
FFTSignal_x2=2/N*fft(Signal_x2);
subplot(2,1,2)
Fnsin_x2=abs(FFTSignal_x2);
%FW=2*pi*Time/Endtime;
plot(FW(2:length(FW))*Fs/pi/2,Fnsin_x2(2:length(FW)));
hold on
plot((FW(2:length(FW))-2*pi)*Fs/pi/2,Fnsin_x2(2:length(FW)));
xlim([-Fs/2 Fs/2]);
xlabel('Frequence');
%绘制x3(t)
figure
subplot(2,1,1);
plot(Time,Signal_x3);
xlabel('Time');
xlim([0 0.05])
title('时域信号 x3(t)');
FFTSignal_x3=2/N*fft(Signal_x3);
subplot(2,1,2)
Fnsin_x3=abs(FFTSignal_x3);
%FW=2*pi*Time/Endtime;
plot(FW(2:length(FW))*Fs/pi/2,Fnsin_x3(2:length(FW)));
hold on
plot((FW(2:length(FW))-2*pi)*Fs/pi/2,Fnsin_x3(2:length(FW)));
xlim([-Fs/2 Fs/2]);
xlabel('Frequence');
%绘制信号x(t)
figure
subplot(2,1,1);
plot(Time,Signal_x);
xlabel('Time');
xlim([0 0.05])
title('时域信号 x(t)');
FFTSignal_x=2/N*fft(Signal_x);
subplot(2,1,2);
Fnsin_x=abs(FFTSignal_x);
plot(FW(2:length(FW))*Fs/pi/2,Fnsin_x(2:length(FW)));
hold on
plot((FW(2:length(FW))-2*pi)*Fs/pi/2,Fnsin_x(2:length(FW)));
xlim([-Fs/2 Fs/2]);
xlabel('Frequence');
%输入x(t),输出y(t)
figure;
subplot(2,1,1);
YLP=filter(num,den,Signal_x);
plot(Time,YLP);
xlim([0 0.05]);
xlabel('时间');
title('高通滤波后的时域信号');
FFTSignalsum_x=2/N*fft(YLP);
subplot(2,1,2);
Fnsinsum_x=abs(FFTSignalsum_x);
plot(FW(2:length(FW))*Fs/pi/2,Fnsinsum_x(2:length(FW)));
hold on
plot((FW(2:length(FW))-2*pi)*Fs/pi/2,Fnsinsum_x(2:length(FW)));
xlim([-Fs/2 Fs/2]);
ylim([0 1]);
xlabel('Frequence');