数字信号处理实验全部程序MATLAB

上传人:xmg****18 文档编号:121233265 上传时间:2020-02-19 格式:DOC 页数:26 大小:290KB
返回 下载 相关 举报
数字信号处理实验全部程序MATLAB_第1页
第1页 / 共26页
数字信号处理实验全部程序MATLAB_第2页
第2页 / 共26页
数字信号处理实验全部程序MATLAB_第3页
第3页 / 共26页
数字信号处理实验全部程序MATLAB_第4页
第4页 / 共26页
数字信号处理实验全部程序MATLAB_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《数字信号处理实验全部程序MATLAB》由会员分享,可在线阅读,更多相关《数字信号处理实验全部程序MATLAB(26页珍藏版)》请在金锄头文库上搜索。

1、.专业整理.实验一 熟悉MATLAB环境一、实验目的(1)熟悉MATLAB的主要操作命令。(2)学会简单的矩阵输入和数据读写。(3)掌握简单的绘图命令。(4)用MATLAB编程并学会创建函数。(5)观察离散系统的频率响应。二、实验内容认真阅读本章附录,在MATLAB环境下重新做一遍附录中的例子,体会各条命令的含义。在熟悉了MATLAB基本命令的基础上,完成以下实验。上机实验内容:(1)数组的加、减、乘、除和乘方运算。输入A=1 2 3 4,B=3 4 5 6,求C=A+B,D=A-B,E=A.*B,F=A./B,G=A.B并用stem语句画出A、B、C、D、E、F、G。实验程序:A=1 2 3

2、 4;B=3 4 5 6;n=1:4;C=A+B;D=A-B;E=A.*B;F=A./B;G=A.B;subplot(4,2,1);stem(n,A,fill);xlabel (时间序列n);ylabel(A);subplot(4,2,2);stem(n,B,fill);xlabel (时间序列n );ylabel(B);subplot(4,2,3);stem(n,C,fill);xlabel (时间序列n );ylabel(A+B);subplot(4,2,4);stem(n,D,fill);xlabel (时间序列n );ylabel(A-B);subplot(4,2,5);stem(n,

3、E,fill);xlabel (时间序列n );ylabel(A.*B);subplot(4,2,6);stem(n,F,fill);xlabel (时间序列n );ylabel(A./B);subplot(4,2,7);stem(n,G,fill);xlabel (时间序列n );ylabel(A.B);运行结果:(2)用MATLAB实现以下序列。a)x(n)=0.8n 0n15实验程序:n=0:15;x=0.8.n;stem(n,x,fill); xlabel (时间序列n );ylabel(x(n)=0.8n);b)x(n)=e(0.2+3j)n 0n15实验程序:n=0:15;x=ex

4、p(0.2+3*j)*n);stem(n,x,fill); xlabel (时间序列n );ylabel(x(n)=exp(0.2+3*j)*n);运行结果:a)的时间序列 b)的时间序列c)x(n)=3cos(0.125n+0.2)+2sin(0.25n+0.1) 0n15实验程序:n=0:1:15;x=3*cos(0.125*pi*n+0.2*pi)+2*sin(0.25*pi*n+0.1*pi);stem(n,x,fill); xlabel(时间序列n );ylabel(x(n)=3*cos(0.125*pi*n+0.2*pi)+2*sin(0.25*pi*n+0.1*pi);运行结果:

5、d)将c)中的x(n)扩展为以16为周期的函数x16(n)=x(n+16),绘出四个周期实验程序:n=0:1:63;x=3*cos(0.125*pi*rem(n,16)+0.2*pi)+2*sin(0.25*pi*rem(n,16)+0.1*pi);stem(n,x,fill); xlabel (时间序列n );ylabel(x16(n);e)将c)中的x(n)扩展为以10为周期的函数x10(n)=x(n+10),绘出四个周期实验程序:n=0:1:39;x=3*cos(0.125*pi*rem(n,10)+0.2*pi)+2*sin(0.25*pi*rem(n,10)+0.1*pi);stem

6、(n,x,fill); xlabel (时间序列n );ylabel(x10(n);运行结果:d)的时间序列 e)的时间序列(3)x(n)=1,-1,3,5,产生并绘出下列序列的样本。a)x1(n)=2x(n+2)-x(n-1)-2x(n)实验程序:n=0:3;x=1 -1 3 5;x1=circshift(x,0 -2);x2=circshift(x,0 1);x3=2*x1-x2-2*x;stem(x3,fill); xlabel (时间序列n );ylabel(x1(n)=2x(n+2)-x(n-1)-2x(n);b)实验程序:n=0:3;x=1 -1 3 5;x1=circshift(

7、x,0 1);x2=circshift(x,0 2);x3=circshift(x,0 3);x4=circshift(x,0 4);x5=circshift(x,0 5);xn=1*x1+2*x2+3*x3+4*x4+5*x5;stem(xn,fill); xlabel(时间序列n );ylabel(x2(n)=x(n-1)+2x(n-2)+3x(n-3)+4x(n-4)+5x(n-5);运行结果: a)的时间序列b)的时间序列(4)绘出时间函数的图形,对x轴、y轴图形上方均须加上适当的标注。 a) x(t)=sin(2t) 0t10s b) x(t)=cos(100t)sin(t) 0t4

8、s实验程序:clc;t1=0:0.001:10;t2=0:0.01:4;xa=sin(2*pi*t1);xb=cos(100*pi*t2).*sin(pi*t2);subplot(2,1,1);plot(t1,xa);xlabel (t);ylabel(x(t);title(x(t)=sin(2*pi*t);subplot(2,1,2);plot(t2,xb);xlabel (t);ylabel(x(t);title(x(t)=cos(100*pi*t2).*sin(pi*t2);运行结果:(5)编写函数stepshift(n0,n1,n2)实现u(n-n0),n1n0=0;stem(n,x,

9、fill);xlable(时间序列n);ylable(u(n-n0);请输入起点:2请输入终点:8请输入阶跃位置:6运行结果: (5)运行结果 (6)运行结果(6)给一定因果系统求出并绘制H(z)的幅频响应与相频响应。实验程序:a=1 -0.67 0.9;b=1 sqrt(2) 1;h w=freqz(b,a);fp=20*log(abs(h);subplot(2,1,1);plot(w,fp);xlabel(时间序列t);ylabel(幅频特性);xp=angle(h);subplot(2,1,2);plot(w,xp);xlabel(时间序列t);ylabel(相频特性);运行结果:(右上

10、图)常用典型序列单位采样序列function x,n=impseq(n1,n2,n0) n=n1:n2; x=(n-n0)=0;x,n=impseq(-2,8,2);stem(n,x);title(电信1201)n0=-2;n=-10:10;nc=length(n);x=zeros(1,nc);for i=1:nc if n(i)=n0 x(i)=1 endendstem(n,x) ;title(电信1201 采样序列第二种方法)单位阶跃序列function x,n=stepseq(n1,n2,n0) n=n1:n2; x=(n-n0)=0;x,n=stepseq(-2,8,2);stem(n

11、,x);title(电信1201)实数指数n=0:10;x=0.9.n;stem(n,x);title(电信1201)复数指数序列n=-10:10;alpha=-0.1+0.3*j;x=exp(alpha*n);real_x=real(x); image_x=imag(x);mag_x=abs(x); phase_x=angle(x);subplot(2,2,1); stem(n,real_x) ;title(电信1201)subplot(2,2,2); stem(n,image_x);title(电信1201)subplot(2,2,3); stem(n,mag_x);title(电信120

12、1)subplot(2,2,4); stem(n,phase_x);title(电信1201)正余弦n=0:10;x=3*cos(0.1*pi*n+pi/3);stem(n,x);title(电信1201)例: 求出下列波形x1(n)=2x(n-5)-3x(n+4)function y,n=sigadd(x1,n1,x2,n2) n=min(min(n1),min(n2) : max(max(n1),max(n2); y1=zeros(1,length(n); y2=y1; y1(find(n=min(n1)&(n=min(n2)&(n=max(n2)=1)=x2; y=y1+y2;funct

13、ion y,n=sigshift(x,m,n0) n=m+n0; y=x; n=-2:10;x=1:7,6:-1:1;x11,n11=sigshift(x,n,5);x12,n12=sigshift(x,n,-4);x1,n1=sigadd(2*x11,n11,-3*x12,n12);stem(n1,x1);title(电信1201)已知某一系统方程为:yn-yn-1+0.9yn-2=xn计算并画出脉冲响应h(n),n=(-20,100)n=(-20:100);num=(1); den=1 -1 0.9;x=impseq(-20,100,0);h=filter(num,den,x);stem(n,h)xlabel(时间序号N);ylabel(脉冲响应h);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号