医学信号处理实验报告

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
H=freqz(num,den,w);
magH=abs(H);phaH=angle(H);
subplot(2,2,2);plot(w/pi,magH);grid;
xlabel('ƵÂÊ µ¥Î»:pi');ylabel('·ù¶È');
title('ƵÂÊÏìÓ¦');
subplot(2,2,3);
运行结果:
第二题:
源代码:
num=[-1 0.4 0.45];
den=[0.45 0.4 -1];
[z,p,k]=tf2zp(num,den);
n=0:20;
x=2.*0.9.^n.*[n>=0];
y=filter(num,den,x);
subplot(2,2,1);
zplane(z,p);
w=[0:1:512]*pi/512;
ylabel('amplitude');
x=[n>=0];
x=double(x);
s=conv(x,h);
subplot(2,1,2);
n=-10:0.5:40;
stem(n,s);
title('step response');
xlabel('time');
ylabel('amplitude');
运行结果:
plot(w/pi,phaH);grid;
xlabel('ƵÂÊ µ¥Î»:pi');ylabel('Ïàλ');
title('ÏàλÏìÓ¦');
subplot(2,2,4);
plot(n,y);grid;
xlabel('n');ylabel('y');
title('y(n)');
运行结果:
理论计算结果及对比分析:
答:通过理论计算得到n=0,1,2,3,4五个点的结果分别为:
n=0: h(n)=0
n=1,2,3,4时h(n)=0.25
利用得到的单位冲击响应函数求得卷积的结果(取五个点)分别为0,0.25,0. 5,0.75,1
对比图像,理论结果与实验结果一致
实验三:
第一题(书上有参考代码,不再赘述)
xlabel('n');
ylabel('xtilde(n)');
运行结果:
实验七:
第一题:
源代码:
n=50;
Wn=0.45;
b1=fir1(n,Wn,boxcar(n+1));
[H,w]=freqz(b1,1,512,2);
subplot(4,1,1);
plot(w,abs(H));grid;
title('矩形窗低通FIR数字滤波器');
实验四:
第一题(书上有参考代码,不再赘述)
运行结果:
DFT:
DTFT:
第二题:
(1)源代码:
n=0:15;
x=n.*(1./n).*[n<5];
x(1)=1;
k=-200:200;
w=(pi/100)*k;
y=x*(exp(-j*pi/100)).^(n'*k);
subplot(4,1,1);
stem(n,x);
gridon;
n=-40:0.5:40;
x1=cos(0.3.*pi.*n);
subplot(3,1,3);
stem(n,x1);
title('cos(0.3.*pi.*n)');
xlabel('n');
ylabel('x1(n)');
gridon;
运行结果:
A小问:cos(0.3pin)(-20<=n<=20)的基本周期是20,cos(0.4pin)(-20<=n<=20)的基本周期是5。N和K的意义是:
subplot(2,2,4);
stem(n,x4);
title('x1+x2+x3');
xlabel('n');
ylabel('x(n)');
运行结果:
第二题第二小题
源代码:
n=-20:0.5:20;
x1=cos(0.3.*pi.*n);
x2=cos(0.4.*pi.*n);
subplot(3,1,1);
title('n*n*[u(n+5£©-u(n-6)]');
xlabel('n');
ylabel('x(n)');
x2=10.*[n==0];
subplot(2,2,2);
stem(n,x2);
title('10*[n==0]');
xlabel('n');
ylabel('x(n)');
x3=20.*0.5.^n.*([n>=4]-[n>=10]);
N=16;
k=0:1:N-1;
w=2*pi*k/N;
z=exp(j*w);
Xk=(z)./(z-0.8);
xn=real(ifft(Xk,N));
xtilde=xn'*ones(1,8);
xtilde=(xtilde(:))';
subplot(2,1,2);
stem(0:127 ,xtilde);
title('16µãµÄIFFT·ù¶ÈÆ×');
stem(n,x1);
title('cos(0.3.*pi.*n)');
xlabel('n');
ylabel('x1(n)');
gridபைடு நூலகம்n;
subplot(3,1,2);
stem(n,x2);
title('cos(0.4.*pi.*n)');
xlabel('n');
ylabel('x2(n)');
运行结果:
第二题:
n=50;
Wn=0.65,
b1=fir1(n,Wn,'high',boxcar(n+1));
[H,w]=freqz(b1,1,512,2);
subplot(4,1,1);
plot(w,abs(H));grid;
title('矩形窗高通FIR数字滤波器');
b2=fir1(n,Wn,'high',hanning(n+1));
医学信号处理实验报告
班级:生医1201
姓名:葛然
学号:12282002
实验一:
基本函数图形(书上有参考代码,不再赘述)
第一题(书上有参考代码,不再赘述)
第二题第一小题
源代码:
n=-10:0.5:10;
x1=n.*n.*([n>=-5]-[n>=6]);
subplot(2,2,1);
stem(n,x1);
title('resource');
subplot(4,1,2);
stem(w/pi,abs(y));
title('magnitude');
subplot(4,1,3);
stem(w/pi,angle(y));
title('phase');
运行结果:
(2)源代码:
N=10;
n=0:9;
x=n.*(1./n).*[n<5];
[H,w]=freqz(b2,1,512,2);
subplot(4,1,2);
plot(w,abs(H));grid;
title('汉宁窗带阻FIR数字滤波器');
b3=fir1(n,Wn,'stop',hamming(n+1));
第二题:
源代码:
p=[0.25,0.25,0.25,0.25];
d=[1];
n=-5:0.5:20;
x=[n==0];
x=double(x);
h=filter(p,d,x);
subplot(2,1,1);
stem(n,h);
title('impulse response');
xlabel('time');
title('phase');
subplot(4,1,4);
stem(n,x1);
title('resumed signal');
运行结果:
实验五:
第一题(书上有参考代码,不再赘述)
运行结果:
第二题
源代码:
N=64;
k=0:1:N-1;
w=2*pi*k/N;
z=exp(j*w);
Xk=(z)./(z-0.8);
subplot(4,1,3);
plot(w,abs(H));grid;
title('海明窗低通FIR数字滤波器');
b4=fir1(n,Wn,blackman(n+1));
[H,w]=freqz(b4,1,512,2);
subplot(4,1,4);
plot(w,abs(H));grid;
title('希拉克曼窗低通FIR数字滤波器');
答:此序列是非周期的,对比a组中的结论我们可得到一下结论:1)当2*pi/w0是整数或者有理数时,K取适当的整数值可以得到最小周期如前两个图所示;2)当2*pi/w0是一个无理数时,任何的K值都不能使得N为正整数,所以余弦序列是非周期的,如第三个图所示。
实验二:
第一题(书上有参考代码,不再赘述)
运行结果:
[H,w]=freqz(b2,1,512,2);
subplot(4,1,2);
plot(w,abs(H));grid;
title('汉宁窗高通FIR数字滤波器');
b3=fir1(n,Wn,'high',hamming(n+1));
[H,w]=freqz(b3,1,512,2);
subplot(4,1,3);
plot(w,abs(H));grid;
title('海明窗高通FIR数字滤波器');
b4=fir1(n,Wn,'high',blackman(n+1));
[H,w]=freqz(b4,1,512,2);
subplot(4,1,4);
plot(w,abs(H));grid;
title('希拉克曼窗高通FIR数字滤波器');
运行结果:
第四题:
n=50;
Wn=[0.45,0.65];
b1=fir1(n,Wn,'stop',boxcar(n+1));
[H,w]=freqz(b1,1,512,2);
subplot(4,1,1);
plot(w,abs(H));grid;
title('矩形窗带阻FIR数字滤波器');
b2=fir1(n,Wn,'stop',hanning(n+1));
x(1)=1;
y=fft(x,N);
x1=ifft(y,N);
subplot(4,1,1);
stem(n,x);
title('original signal');
subplot(4,1,2);
stem(n,abs(y));
title('magnitude');
subplot(4,1,3);
stem(n,angle(y));
xn=real(ifft(Xk,N));
xtilde=xn'*ones(1,2);
xtilde=(xtilde(:))';
subplot(2,1,1);
stem(0:127,xtilde);
title('64µãµÄIFFT·ù¶ÈÆ×');
xlabel('n');
ylabel('xtilde(n)');
plot(w,abs(H));grid;
title('海明窗带通FIR数字滤波器');
b4=fir1(n,Wn,'bandpass',blackman(n+1));
[H,w]=freqz(b4,1,512,2);
subplot(4,1,4);
plot(w,abs(H));grid;
title('希拉克曼窗带通FIR数字滤波器');
b2=fir1(n,Wn,hanning(n+1));
[H,w]=freqz(b2,1,512,2);
subplot(4,1,2);
plot(w,abs(H));grid;
title('汉宁窗低通FIR数字滤波器');
b3=fir1(n,Wn,hamming(n+1));
[H,w]=freqz(b3,1,512,2);
答:由上图可以看出cos(0.3*pi*n)是周期序列,基本的周期是20.序列cos(0.4*pi*n)是周期为5的周期序列。对比两者可得N实际上是基波的周期,基波的频率为2*pi/N而K是一个任意的正整数与N互为素数。
B小问:cos(0.3pin)(-40<=n<=40)序列是周期的,周期是20。结论是周期只与cos(wn)中的w有关,在计算机中,pi被定义为有限长小数,所以周期相同。
[H,w]=freqz(b2,1,512,2);
subplot(4,1,2);
plot(w,abs(H));grid;
title('汉宁窗带通FIR数字滤波器');
b3=fir1(n,Wn,'bandpass',hamming(n+1));
[H,w]=freqz(b3,1,512,2);
subplot(4,1,3);
subplot(2,2,3);
stem(n,x3);
title('20.*0.5.^n.*([n>=4]-[n>=10])');
xlabel('n');
ylabel('x(n)');
x4=n.*n.*([n>=-5]-[n>=6])+10.*[n==0]+20.*0.5.^n.*([n>=4]-[n>=10]);
运行结果:
第三题:
n=50;
Wn=[0.45,0.65];
b1=fir1(n,Wn,'bandpass',boxcar(n+1));
[H,w]=freqz(b1,1,512,2);
subplot(4,1,1);
plot(w,abs(H));grid;
title('矩形窗带通FIR数字滤波器');
b2=fir1(n,Wn,'bandpass',hanning(n+1));
相关文档
最新文档