四、思考题 1、程序如下:
fid=fopen('104.txt','r');
[fecg,count]=fscanf(fid,'%f%f',1800); fclose(fid); t=0:1/360:(5-1/360); xecg=fecg';
xma=0.1*sin(2*pi*200*t); x0=xecg+xma; subplot(411) plot(t,xecg); grid on; subplot(412) plot(t,x0); grid on;
[bma,ama]=butter(3,100/180); xl=filter(bma,ama,x0); subplot(413) plot(t,xl); grid on; num=bma; den=ama; w=0:pi/511:pi; h=freqz(num,den,w); f=w*180/pi; subplot(414) plot(f,abs(h)); axis([0 180 0 1.4]); grid on
运行结果如下:
20-220-220-210.5002040608010012014016018000.511.522.533.544.5500.511.522.533.544.5500.511.522.533.544.55
2、为了消除基线漂移,应设计一高通滤波器。由于在高通滤波器的通带截止频率、通带截止频率处增益和阻带截止频率处增益与低通滤波器相同的情况下,高通滤波器的阶数和低通滤波器的阶数相同。因此可以求相应低通滤波器的阶数。求阶数的计算方法如下: A.模拟截止频率分别为:fp1?0.3Hz,fs1?0.5Hz B.通带截止频率处得增益为:20log(1??p)??0.5dB 阻带截止频率处得增益为:20log?s??25dB C.数字截止频率为:?p1?2?fp1fs?2?0.31?? 360600
?s1?2?fs10.51?2??? fs360360D.预变换模拟截止频率:?p1?2fstan(?p1/2)?3.7440 ?s1?2fstan(?s1/2)?6.2640 E.1??p?10?1/40 ??1(1??p)12?1? 0.508 8
?s?10?25/20
???2s?1?17.7547
F.
17.7547)0.5088? 4.2453?3.8475n???6.2640)1.1034cosh?1(s1)cosh?1(3.7440?p1cosh?1()cosh?1(因此且比雪夫滤波器的阶数为:4
MATLAB程序如下:
fid=fopen('104.txt','r');
[fecg,count]=fscanf(fid,'%f%f',1800); fclose(fid); t=0:1/360:(5-1/360); xecg=fecg';
xbw=0.5*sin(2*pi*0.2*t); x0=xecg+xbw; subplot(411) plot(t,xecg); grid on subplot(412) plot(t,x0) grid on
[bbw,abw]=cheby1(4,0.5,0.3/180,'high'); xh=filter(bbw,abw,x0); subplot(413) plot(t,xh); grid on num=bbw; den=abw; w=0:pi/511:pi; h=freqz(bbw,abw,w); f=w*180/pi; subplot(414) plot(f,abs(h)); axis([0 20 0 1.4]); grid on
??.
运行结果如下:
20-220-220-210.500246810121416182000.511.522.533.544.5500.511.522.533.544.5500.511.522.533.544.55
3、为了消除工频干扰,需要设计一带阻FIR滤波器。将滤波器截止频率上限选为55Hz,滤波器截止频率下限选为65Hz,带宽选为5Hz,窗函数选择Hanning窗。据表中的计算式得到此滤波器项数为N?3.32360,约等于239,阶数为238。项数必须为奇数。 5N?1 2Number of Terms, N Filter Stop Band Attenuation (dB) 21 44 55 75 64 81 100 Window Type Window Function n?Rectangular Hanning Hamming Blackman Kaiser fs T.W.f2?n0.5?0.5cos() 3.32s N?1T.W.f2?n0.54?0.46cos() 3.44s N?1T.W.f2?n4?n0.42?0.5cos()?0.08cos() 5.98s N?1N?1T.W.f4.33s???6? 2T.W.?2n????I0??1??fs???N?15.25???8? ????T.W. I0???f6.36s???10? T.W.1 0.91N = number of terms in windows,fs= sampling frequency, T.W.= transition width.
MATLAB程序如下:
fid=fopen('104.txt','r');
[fecg,count]=fscanf(fid,'%f%f',1800); fclose(fid); t=0:1/360:(5-1/360); xecg=fecg';
xn=0.1*sin(2*pi*60*t); x0=xecg+xn; subplot(411) plot(t,xecg); grid on subplot(412) plot(t,x0); grid on
b0=fir1(238,[55/180,65/180],'stop'); xs=filter(b0,1,x0); subplot(413) plot(t,xs); grid on num=b0; den=1; w=0:pi/511:pi; h=freqz(num,den,w); f=w*180/pi; subplot(414) plot(f,abs(h)); axis([0 180 0 1.4]); grid on
运行结果如下:
20-220-220-210.5002040608010012014016018000.511.522.533.544.5500.511.522.533.544.5500.511.522.533.544.55