已阅读5页,还剩28页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
信号与系统MATLAB实验报告陈宸 F0803008 5080309348实验二 离散时间信号与系统一 实验目的 1 了解信号处理的基本操作 2 熟悉一些常用的序列及其应用 二实验原理我们所接触的信号大多为连续信号,为使之便于处理,往往要对其进行采样,对信号抽样并保证其能完全恢复,对抽样频率有一定的限制。 基本的离散序列的定义如下: 1 单位采样序列 2 单位阶跃序列 3 实指数序列 4 复数指数序列 5 正余弦序列 6 周期序列 三实验内容 1.用MATLAB实现函数impseq(n0,n1,n2),使函数实现,。该函数的格式为:Function x,n=impseq(n0,n1,n2)% Generate x(n)=delta(n-n0);n1=nn2 error(n1 should smaller than or equal to n2.);endn=n1:n2;x=zeros(1,n2-n1+1);if n0=n1 & n0x n=impseq(2,-1,4)x = 0 0 0 1 0 0n = -1 0 1 2 3 4 2.MATLAB实现函数stepseq(n0,n1,n2),使函数实现u(n-n0),。该函数的格式为:function x,n=stepseq(n0,n1,n2)%Generate x(n)=u(n-n0);n1=nn2 error(n1 should smaller than or equal to n2.);endn=n1:n2;x=zeros(1,n2-n1+1);if n0=n1 x=x+1;elseif n0x n=stepseq(2,-1,4)x = 0 0 0 1 1 1n = -1 0 1 2 3 43用MATLAB实现下列序列a. 程序: n=0:10;x=(0.9).n 运行结果:x = 1.0000 0.9000 0.8100 0.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.3487b. 程序n=0:10;x=exp(2+3j)*n) 运行结果:x = 1.0e+008 * Columns 1 through 7 0.0000 -0.0000 + 0.0000i 0.0000 - 0.0000i -0.0000 + 0.0000i 0.0000 - 0.0000i -0.0002 + 0.0001i 0.0011 - 0.0012i Columns 8 through 11 -0.0066 + 0.0101i 0.0377 - 0.0805i -0.1918 + 0.6280i 0.7484 - 4.7936ic. 程序n=0:10;x=3*cos(0.1*pi*n+pi/3)+2*sin(0.5*pi*n)运行结果:x =1.5000 2.6237 -0.3136 -3.2202 -2.0074 -0.5981 -2.9344 -4.9836 -2.7406 -0.2294 -1.5000d. 将c中的扩展为,周期数为4程序 n=0:10;x=3*cos(0.1*pi*n+pi/3)+2*sin(0.5*pi*n);xtilde=x,x,x,x;4MATLAB中可用算术运算符“+”实现信号相加,但和的长度必须相等。如果序列长度不等,或者长度虽然相等但采样的位置不同,就不能运用“+”了。试用MATLAB写出任意序列相加的函数sigadd,其格式如下:Function % 实现 % % y=在包括n1和n2的n上求和序列% x1=长为n1的第一个序列,x2=长为n2的第二个序列(n2 可与n1不等)程序: function y,n=sigadd(x1,n1,x2,n2) n=min(min(n1),min(n2):max(max(n1),max(n2); %y(n)的长度% y1=zeros(1,length(n);y2=y1); %初始化% y1(find(n=min(n1)&(n=min(n2)&(n=min(n1)&(n=min(n2)&(n x n=impseq(0,-5,5)x = 0 0 0 0 0 1 0 0 0 0 0n = -5 -4 -3 -2 -1 0 1 2 3 4 5 y m=sigshift(x,n,2)y = 0 0 0 0 0 1 0 0 0 0 0m = -3 -2 -1 0 1 2 3 4 5 6 77建立一个函数sigfold,实现。MATLAB中,这一运算由fliplr(x)函数实现,而对采样位置则由-fliplr(n)得到。格式与上类同。程序:function y,n=sigfold(x,m)y=fliplr(x);n=-fliplr(m);运行结果: x m=stepseq(1,-5,5)x = 0 0 0 0 0 0 1 1 1 1 1m = -5 -4 -3 -2 -1 0 1 2 3 4 5 y n=sigfold(x,m)y = 1 1 1 1 1 0 0 0 0 0 0n = -5 -4 -3 -2 -1 0 1 2 3 4 58用 MATLAB产生并画出(用stem 函数)下列序列的样本:a) 程序:function x,n=seq8an=0:25;x=0:25;for m=0:10 x=x+(impseq(2*m,0,25)-impseq(2*m+1,0,25)*(m+1);endstem(n,x);运行结果: seq8aans = Columns 1 through 19 1 0 4 1 7 2 10 3 13 4 16 5 19 6 22 7 25 8 28 Columns 20 through 26 9 31 10 22 23 24 25图:b) 程序:function x,n=seq8bn=-7:7;x=-7:7;x=n.*n.*(stepseq(-5,-7,7)-stepseq(6,-7,7)+10*impseq(0,-7,7)+20*(0.5.n).*(stepseq(4,-7,7)-stepseq(10,-7,7);stem(n,x);运行结果: x n=seq8bx = 0 0 25 16 9 4 1 0 1 4 9 16 25 0 0ans = 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0ans = 0 0 25 16 9 4 1 0 1 4 9 16 25 0 0图:c) 程序:function x,n=seq8cn=0:20;x=0:20;x=0.9.n.*(cos(0.2*pi*n)+1/3*pi);stem(n,x);运行结果: x n=seq8cans = Columns 1 through 11 2.0472 1.6706 1.0985 0.5381 0.1563 0.0279 0.1266 0.3531 0.5838 0.7191 0.7138 Columns 12 through 21 0.5825 0.3830 0.1876 0.0545 0.0097 0.0441 0.1231 0.2036 0.2507 0.2489图:d) (其中是一个在0,1之间均匀分布的随机序列,用rand(1,N)实现,其中N表示长度)程序:function x,n=seq8dn=0:100;x=0:100;x=10*cos(0.0008*pi*(n.*n)+rand(1,101);stem(n,x);运行结果: x n=seq8dans = Columns 1 through 11 10.9501 10.2311 10.6063 10.4834 10.8832 10.7424 10.4156 9.9428 10.6923 10.2382 10.3013 Columns 12 through 22 10.3331 10.2740 9.8497 8.9873 8.8490 8.9361 8.3930 7.2740 7.0525 5.4162 4.8142 Columns 23 through 33 4.2832 2.3993 1.3673 0.2028 -1.0795 -1.9804 -3.6184 -4.9671 -6.3590 -6.7293 -7.9847 Columns 34 through 44 -8.2606 -9.2562 -9.5616 -9.0870 -9.0309 -8.6321 -7.0967 -5.5361 -4.6652 -2.0724 -0.2735 Columns 45 through 55 2.3589 4.1841 6.4028 7.8715 9.1157 9.8817 10.1934 10.3618 9.0170 7.6747 5.1654 Columns 56 through 66 3.1848 0.1019 -2.2062 -4.7983 -7.2068 -8.8012 -9.0737 -8.9006 -7.8782 -5.6334 -3.0210 Columns 67 through 77 -0.1354 3.1158 6.1987 8.7836 10.4129 10.2562 9.7882 7.3399 4.0283 0.7027 -3.1580 Columns 78 through 88 -6.4735 -8.4477 -9.3761 -8.5029 -6.1408 -3.1820 1.2319 4.5667 8.6849 9.9318 10.1023 Columns 89 through 99 9.0536 5.6427 0.7644 -3.8093 -6.6321 -9.4804 -9.4686 -7.0437 -3.6062 1.3227 5.5077 Columns 100 through 101 9.7635 10.5828图:e) ,画出五个序列程序:function x,n=seq8en=0:19;x=zeros(1,20);p=zeros(1,20);p=p+stepseq(0,0,19);for i=1:10 p=p+2*(-1)i*stepseq(2*i,0,19);endx(1)=1;for i=2:20 x(i)=x(i-1)+p(i-1);endstem(n,x);运行结果: x n=seq8ex = Columns 1 through 14 1 2 3 2 1 2 3 2 1 2 3 2 1 2 Columns 15 through 20 3 2 1 2 3 2n = Columns 1 through 14 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Columns 15 through 20 14 15 16 17 18 19图:9令x(n)=1,-2,4,6,-5,8,10,产生并画出下列序列的样本a) 程序:function x1,n=seq9ax=1 -2 4 6 -5 8 10;m=0:6;xtemp ntemp=sigshift(x,m,-2);xtemp1 ntemp1=sigshift(x,m,4);xtemp ntemp=sigadd(3*xtemp,ntemp,xtemp1,ntemp1);x1 n=sigadd(xtemp,ntemp,-2*x,m);stem(n,x1);运行结果: x n=seq9ax = 3 -6 10 22 -23 12 41 -18 -16 6 -5 8 10n = -2 -1 0 1 2 3 4 5 6 7 8 9 10图:b) 程序:function x1,n=seq9bx=1 -2 4 6 -5 8 10;m=0:6;n=0;x1=0;for k=1:5 xtemp ntemp=sigshift(x,m,k); x1 n=sigadd(x1,n,ntemp.*xtemp,ntemp);endstem(n,x1);运行结果: x n=seq9bx = 0 1 -2 9 36 20 66 161 152 117 180 110n = 0 1 2 3 4 5 6 7 8 9 10 11图:10将题9中的序列分解为偶和奇分量。用stem画出这些分量 其中偶部: 奇部:创建函数evenodd,实现奇偶分量程序:function xe,ne,xo,no=evenodd(x,n)xtemp,ntemp=sigfold(x,n);xe,ne=sigadd(x,n,xtemp,ntemp);xe=xe/2;xo,no=sigadd(x,n,-xtemp,ntemp);xo=xo/2;运行结果: x n=seq9a; xe ne xo no=evenodd(x,n)xe = Columns 1 through 8 5.0000 4.0000 -2.5000 3.0000 -8.0000 -9.0000 20.5000 6.0000 Columns 9 through 16 -10.0000 8.0000 10.0000 8.0000 -10.0000 6.0000 20.5000 -9.0000 Columns 17 through 21 -8.0000 3.0000 -2.5000 4.0000 5.0000ne = Columns 1 through 14 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 Columns 15 through 21 4 5 6 7 8 9 10xo = Columns 1 through 8 -5.0000 -4.0000 2.5000 -3.0000 8.0000 9.0000 -20.5000 -6.0000 Columns 9 through 16 13.0000 -14.0000 0 14.0000 -13.0000 6.0000 20.5000 -9.0000 Columns 17 through 21 -8.0000 3.0000 -2.5000 4.0000 5.0000no = Columns 1 through 14 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 Columns 15 through 21 4 5 6 7 8 9 10 subplot(3,1,1),stem(n,x) subplot(3,1,2),stem(ne,xe) subplot(3,1,3),stem(no,xo)图:(图中由上至下依次是:n-x,ne-xe,no-xo图)11考虑模拟信号。分别用Ts=0.5,0.25,0.1秒时的采样 间隔对它采样以获得x(n),对每个Ts,画出x(n),讨论所得结果。程序:function x,t=t11(ts)t=0:ts:1;x=1:(1/ts+1);for i=1:(1/ts+1) x(i)=sin(2*pi*t(i);endstem(t,x),axis(0,1,-1,1);图:Ts=0.1sTs=0.25sTs=0.1s结论: Ts越小,对模拟信号的还原越好.12信号的扩展(或抽取,或降低采样频率)定义为: 其中x(n)的采样频率被降低了整数因子M。a. 开发一个MATLAB函数dnsample, 程序:function y=dnsample(x,M)y=0:fix(length(x)/M);for i=0:fix(length(x)/M) y(i+1)=x(i*M+1);endb. 。频率降低因子为4,求y(n)。用subplot 函数分别画出x(n)和y(n),并对结果进行讨论。程序:function t12bn=-50:50;x=sin(0.125*pi*n);y=dnsample(x,4);ny=0:25;subplot(2,1,1),stem(n,x);subplot(2,1,2),stem(ny,y);运行结果:图:c. 用重复上题,定性地讨论降低采样频率对 信号的影响。程序:function t12cn=-50:50;x=sin(0.5*pi*n);y=dnsample(x,4);ny=0:25;subplot(2,1,1),stem(n,x);subplot(2,1,2),stem(ny,y),axis(0,25,-1,1);运行结果:图:结论:采样频率对于信号的失真度有影响.实验三 卷积实验实验目的1熟悉并验证卷积的性质2利用卷积生成新的波形,建立波形间的联系3验证卷积定理4分析卷积与圆周卷积的区别与联系实验原理信号的卷积是针对时域信号处理的一种分析方法。信号的卷积一般用于求取信号通过某系统后的响应。在信号与系统中,我们通常求取某系统的单位冲激响应,所求得的h(k)可作为系统的时域表征。任意系统的系统响应可用卷积的方法求得: 圆周卷积是数字信号处理的重要内容,由于它也是卷积的一种,必须了解其定义,圆周卷积的条件为卷积长度必须大于每个序列长度和。实验内容1MATLAB提供了一个内部函数conv来计算两个有限长序列的卷积。conv函数假定两个序列都从n=0开始。给出序列x=3,11,7,0,-1,4,2; h=2,3,0,-5,2,1;求两者的卷积y 。将函数conv稍加扩展为函数conv_m,它可以对任意基底的序列求卷积。格式如下: function y,ny=conv_m(x,nx,h,nh) % 信号处理的改进卷积程序 % y,ny=conv_m(x,nx,h,nh) % y,ny=卷积结果 % x,nx=第一个信号 % h,nh=第二个信号 function y,ny=conv_m(x,nx,h,nh) %信号处理的改进卷积程序 % y,ny=conv_m(x,nx,h,nh) % y,ny=卷积结果 % x,nx=第一个信号 % h,nh=第二个信号 nyb=nx(1)+nh(1); nye=nx(length(x)+nh(length(h); ny=nyb:nye; y=conv(x,h); x=3,11,7,0,-1,4,2; nx=-3:3; h=2,3,0,-5,2,1; nh=-1:4; y,ny=conv_m(x,nx,h,nh); % 先 定 义conv_m函 数 , 保 存为conv_m.m文件 figure(1);stem (nx,x); axis(-4 7 -10 12);title(x=3,11,7,0,-1,4,2);xlabel(n); figure(2);stem (nh,h); axis(-4 7 -5 5);title(h=2,3,0,-5,2,1);xlabel(n); figure(3);stem (ny,y);axis(-4 7 -51 50); title(卷积结果 y(n)=x(n)*h(n);xlabel(n); 3对下面三个序列,用conv_m函数,验证卷积特性(交换律、结合律、分配 律、同一律) 交换律 结合律 分配律 同一律 其中:x1(n)=nu(n+10)-u(n-20) x2(n)=u(n)-u(n-30) x3(n)=(1.2)nu(n+5)-u(n-10) N=-20:80;n0=10;k1=zeros(1,10),ones(1,91);k2=zeros(1,40),ones(1,61);k3=zeros(1,20),ones(1,81);k4=zeros(1,50),ones(1,51);k5=zeros(1,15),ones(1,86);k6=zeros(1,30),ones(1,71);u1=k1-k2;u2=k3-k4;u3=k5-k6;%构建信号xn1=N.*u1;xn2=cos(0.1*pi*N).*u2 ;xn3=(1.2.N).*u3;delta=zeros(1,20+n0),1,zeros(1,80-n0);%计算卷积y1,ny1=conv_m(xn1,N,xn2,N);%xn1*xn2%y2,ny2=conv_m(xn2,N,xn1,N);%xn2*xn1%y3,ny3=conv_m(xn2,N,xn3,N);%xn2*xn3%y4,ny4=conv_m(y1,ny1,xn3,N);%(xn1*xn2)*xn3%y5,ny5=conv_m(xn1,N,y3,ny3);%xn1*(xn2*xn3)%y7,ny7=conv_m(xn1,N,xn3,N) ;%xn1*xn3%y8=y1+y7;%xn1*xn2+xn1*xn3%y9,ny9=conv_m(xn1,N,delta,N);%x1n*n-n0%画出信号的图像figure(1);subplot(3,1,1);stem(N,xn1);title(x_1n = n(un+10-un-20);subplot(3,1,2);stem(N,xn2);title(x_2n cos(0.1n)(un-un-30);subplot(3,1,3);stem(N,xn3);title(x_3n =1.2n(un+5-un-10);%画出卷积的图像,验证卷积性质figure(2);subplot(2,1,1);stem (ny1,y1);title(x_1n*x_2n);subplot(2,1,2);stem (ny2,y2);title(x_2n*x_1n);figure(3);subplot(2,1,1);stem (ny4,y4);title(x_1n*x_2n)*x_3n);subplot(2,1,2);stem (ny5,y5);title(x_1n*(x_2n*x_3n);figure(4);subplot(2,1,1);stem(ny9,y9);title(x_1n*n-n0);subplot(2,1,2);stem(N+n0,xn1);title(x_1n-n0);6令 ,其中(MATLAB中函数用sinc表示) 对每一种情况求出其输出y(n)N=-40:60;k1=zeros(1,20),ones(1,81);k2=zeros(1,60),ones(1,41);u1=k1-k2;u2=zeros(1,40),ones(1,61);%构建信号x=3*cos(0.5*pi*N+pi/3)+2*sin(0.3*pi*N);%系统的单位冲击响应h1=0.9.abs(N);h2=sinc(0.2*N).*u1; %sinc函数调用 sinc 表示h3=(0.4.N+0.5.N).*u2%系统输出y1,ny1=conv_m(x,N,h1,N);y2,ny2=conv_m(x,N,h2,N);y3,ny3=conv_m(x,N,h3,N);%画出输出信号的图像figure(1);stem(N,x);title(x=3cos(0.5pin+pi/3)+2sin(0.3pin);figure(2);subplot(3,1,1);stem(N,h1);title(h_1n=0.9|n|);subplot(3,1,2);stem(N,h2);title(h_2n=Sa(0.2n)(un+20-un-20);subplot(3,1,3);stem(N,h3);title(h_3n=(0.4n+0.5n)un);figure(3);subplot(3,1,1);stem(ny1,y1);title(y_1n=xn*h_1n);subplot(3,1,2);stem(ny2,y2);title(y_2n=xn*h_2n);subplot(3,1,3);stem(ny3,y3);title(y_3n=xn*h_3n);实验五 信号调制与解调实验目的1 了解用MATLAB实现信号调制与解调的方法。2 了解几种基本的调制方法。实验原理由于从消息变换过来的原始信号具有频率较低的频谱分量,这种信号在许多信道中不适宜传输。因此,在通信系统的发送端通常需要有调制过程,而在接收端则需要有反调制过程解调过程。所谓调制,就是按调制信号的变化规律去改变某些参数的过程。调制的载波可以分为两类:用正弦信号作载波;用脉冲串或一组数字信号作为载波。最常用和最重要的模拟调制方式是用正弦波作为载波的幅度调制和角度调制。本实验中重点讨论幅度调制。 幅度调制是正弦型载波的幅度随调制信号变化的过程
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 汽车场转让合同范本
- 服装出售童装合同范本
- 土地利用碳收支区域差异分析
- 环境治理监理合同范本
- 派遣制合同制三方协议
- 淘宝店开店合同范本
- 派遣合同补签协议书
- 现代农业供货合同范本
- 经济责任审计合同范本
- 糕点店铺升级合同范本
- 篮球交叉步持球突破教学设计-高二下学期体育与健康人教版
- 1到六年级古诗全部打印
- 转动机械找对轮找中心有图有公式
- BIM-建筑信息模型
- GB/T 22415-2008起重机对试验载荷的要求
- 中国地质大学武汉软件工程专业学位研究生实践手册
- 《投资银行》或《资本运营》风险投资业务课件
- DBJ50T-163-2021 既有公共建筑绿色改造技术标准 清晰正式版
- 低阶煤、褐煤干法制备气化用高浓度水煤浆技术
- GB∕T 37458-2019 城郊干道交通安全评价指南
- DB33_T 2301-2020番茄水肥一体化技术规程(高清正版)
评论
0/150
提交评论