数字信号处理第三章(matlab).doc_第1页
数字信号处理第三章(matlab).doc_第2页
数字信号处理第三章(matlab).doc_第3页
数字信号处理第三章(matlab).doc_第4页
数字信号处理第三章(matlab).doc_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

%计算N点的DFTfunction Xk = dft(xn,N)n=0:1:N-1;k=0:1:N-1;WN=exp(-j*2*pi/N);nk=n*k;WNnk=WN.nk;Xk=xn*WNnkEnd%计算N点的逆DFTfunction xn = idft(Xk,N)n=0:1:N-1;k=0:1:N-1;WN=exp(-j*2*pi/N);nk=n*k;WNnk=WN.(-nk);xn=(Xk*WNnk)/N;end%循环移位函数functiony=cirshift(x,m,N)if length(x)N error( N必须大于等于x(n)的长度)endx=x zeros(1,N-length(x);n=0:N-1;n=mod(n-m,N);y=x(n+1);%计算序列x1(n) 和x2(n)之间的N点循环卷积函数functiony=circonvt(x1,x2,N)if length(x1)N error( N必须大于等于x1的长度)endif length(x2)N error( N必须大于等于x2的长度)endx1=x1 zeros(1,N-length(x1);x2=x2 zeros(1,N-length(x2);m=0:1:N-1;x2=x2(mod(-m,N)+1);H=zeros(N,N);for n=1:1:N H(n,:)=cirshift(x2,n-1,N);endy=x1*H;例3.2(P139) x=1,1,1,1,1,1;n=0:5; k=-200:200;w=(pi/100)*k; X=x*(exp(-j*pi/100).(n*k); magX=abs(X);angX=angle(X)*180/pi; figure(1) subplot(2,1,1);plot(w/pi,magX); axis(-1 1 0 6);grid; title(DTFT的幅度);xlabel(以pi为单位的频率);ylabel(幅度); subplot(2,1,2);plot(w/pi,angX);grid; axis(-1 1 -200 200);title(DTFT的相位); xlabel(以pi为单位的频率);ylabel(相位); N=6; X=dft(x,N); magX=abs(X);phaX=angle(X)*180/pi; k=0:5; figure(2) subplot(2,1,1);stem(k,magX); title(DFT的幅度);xlabel(k); subplot(2,1,2);stem(k,phaX); title(DFT的相位);xlabel(k);Xk = Columns 1 through 5 6.0000 -0.0000 - 0.0000i -0.0000 - 0.0000i 0 - 0.0000i 0.0000 - 0.0000i Column 6 0.0000 - 0.0000i例3.3(P141) n=0:9;x=0.8*cos(0.47*pi*n)+0.4*cos(0.53*pi*n); N=10; X=dft(x,N); magX=abs(X),angX=angle(X) k=0:9; subplot(2,1,1);stem(k,magX);title(DFT的幅度); xlabel(k); subplot(2,1,2);stem(k,angX);title(DFT的相位); xlabel(k);Xk = Columns 1 through 5 1.1611 1.2250 + 0.7289i 2.0522 + 3.5598i 0.9030 - 2.9037i 0.8213 - 0.6744i Columns 6 through 10 0.8360 - 0.0000i 0.8213 + 0.6744i 0.9030 + 2.9037i 2.0522 - 3.5598i 1.2250 - 0.7289imagX = 1.1611 1.4254 4.1090 3.0409 1.0627 0.8360 1.0627 3.0409 4.1090 1.4254angX = 0 0.5367 1.0478 -1.2693 -0.6875 -0.0000 0.6875 1.2693 -1.0478 -0.5367例3.4(P143) n=0:10;x=8*(0.8).n;N=11; y=cirshift(x,6,N); subplot(2,1,1);stem(n,x);title(序列x(n); xlabel(n);ylabel(x(n); subplot(2,1,2);stem(n,y);title(x(n)的循环移位); xlabel(n);ylabel(y(n);例3.5(P144) x1=1,2,2;x2=5,4,3,2,1;N=5; y=circonvt(x1,x2,N)y =11 16 21 16 11例3.6(P144) n=0:9;x1=(0.8).n; n=0:6;x2=exp(-n);N=10; y=circonvt(x1,x2,N)y = 1.0905 1.2008 1.0815 0.9096 0.7440 0.6012 0.4832 0.3866 0.3093 0.2474例3.7(P146) N=32;fs=100;T=1/fs; n=0:N-1;r=n*T;x=r.*exp(r); X=fft(x,N); magX=abs(X),phaX=angle(X) subplot(3,1,1);stem(n,x);axis(0 32 0 1); xlabel(n);title(序列x(n); k=0:N-1; subplot(3,1,2);stem(k,magX);axis(0 32 0 8); xlabel(k);ylabel(DFT的幅度); subplot(3,1,3);stem(k,phaX);axis(0 32 -4 4); xlabel(k);ylabel(DFT的相位);magX = Columns 1 through 10 6.1357 2.2215 1.1182 0.7518 0.5704 0.4630 0.3929 0.3441 0.3087 0.2824 Columns 11 through 20 0.2625 0.2475 0.2363 0.2281 0.2226 0.2194 0.2183 0.2194 0.2226 0.2281 Columns 21 through 30 0.2363 0.2475 0.2625 0.2824 0.3087 0.3441 0.3929 0.4630 0.5704 0.7518 Columns 31 through 32 1.1182 2.2215phaX = Columns 1 through 10 0 1.5747 1.7204 1.8347 1.9411 2.0443 2.1459 2.2467 2.3469 2.4467 Columns 11 through 20 2.5463 2.6457 2.7450 2.8442 2.9434 3.0425 3.1416 -3.0425 -2.9434 -2.8442 Columns 21 through 30 -2.7450 -2.6457 -2.5463 -2.4467 -2.3469 -2.2467 -2.1459 -2.0443 -1.9411 -1.8347 Columns 31 through 32 -1.7204 -1.5747例3.8(P148) N=21;L=256;f1=120;f2=140;fs=400;T=1/fs;ws=2*pi*fs;n=0:N-1;x=cos(2*pi*f1*n*T)+cos(2*pi*f2*n*T);X=fftshift(fft(x,L);w=(-ws/2+(0:L-1)*ws/L)/(2*pi);subplot(2,1,1);plot(w,abs(X);ylabel(幅度谱);xlabel(频率(Hz) N=21);axis(-200 200 0 15);N=11;n=0:N-1;x=cos(2*pi*f1*n*T)+cos(2*pi*f2*n*T);X=fftshift(fft(x,L);subplot(2,1,2);plot(w,abs(X);axis(-200 200 0 25);ylabel(幅度谱);xlabel(频率(Hz) N=11);例3.10(P152) n=0:20; x=cos(0.1*pi*n); h=(0.8).n; L=length(x)+length(h)-1; X=fft(x,L); H=fft(h,L); y=ifft(X.*H) subplot(3,1,1);stem(n,x);ylabel(序列x(n);xlabel(n); subplot(3,1,2);stem(n,h);ylabel(序列h(n);xlabel(n); n=0:L-1; subplot(3,1,3);stem(n,real(y); ylabel(卷积结果y(n);xlabel(n);y = Columns 1 through 10 1.0000 1.7511 2.2099 2.3557 2.1936 1.7548 1.0949 0.2881 -0.5785 -1.4139 Columns 11 through 20 -2.1311 -2.6559 -2.9338 -2.9348 -2.6569 -2.1255 -1.3914 -0.5253 0.3888 1.2621 Columns 21 through 30 2.0097 1.5985 1.2700 1.0086 0.8014 0.6383 0.5106 0.4114 0.3345 0.2751 Columns 31 through 40 0.2288 0.1923 0.1626 0.1375 0.1155 0.0952 0.0762 0.0581 0.0410 0.0254 Column 410.0115例3.11(P153) b=0.0181,0.0543,0.0543,0.0181;a=1,-1.7600,1.1829,-0.2781;ch=impseq(0,0,20);n=0:20;h=filter(b,a,ch);x=cos(0.1*pi*n)+0.32*randn(size(n);L=length(x)+length(h)-1;X=fft(x,L);H=fft(h,L);y=ifft(X.*H)subplot(3,1,1);plot(n,x);axis(0 20 -1.5 1.5);ylabel(信号X(n);xlabel(n);subplot(3,1,2);stem(n,h);axis(0 20 -0.5 0.5);ylabel(系统冲激响应h(n);xlabel(n);n=0:L-1;subplot(3,1,3);plot(n,y);axis(0 20 -1.5 1.5);ylabel(x(n)滤波的结果y(n);xlabel(n);y = Columns 1 through 10 0.0130 0.0795 0.2283 0.4246 0.5909 0.6591 0.6050 0.4556 0.2503 -0.0104 Columns 11 through 20 -0.3476 -0.7126 -0.9934 -1.1208 -1.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论