
实验1 常见离散信号产生和实现(作业1).doc
9页实验实验 1 1 常见离散信号产生和实现常见离散信号产生和实现一、实验目的:一、实验目的:1、加深对常用离散信号的理解; 2、掌握 matlab 中一些基本函数的建立方法二:二:matlabmatlab 使用使用1)创建 M 文件File-New-M-file2)运行Debug->run 注:在试验过程中若有某些函数不懂,可以通过 Help->search->输入要查询的函数名即可二、实验原理:二、实验原理:1.单位抽样序列01)(n00 nn在 MATLAB 中可以利用 zeros()函数实现 1) 1 ();, 1 ( xNzerosx如果在时间轴上延迟了 k 个单位,得到即:)(n)(kn 01)(kn0 nkn2.单位阶跃序列 01)(nu00 nn在 MATLAB 中可以利用 ones()函数实现一个长度为 N 的 1 矩阵);, 1 ( Nonesx 3.正弦序列)/2sin()(FsfnAnx在 MATLAB 中)/***2sin(*1:0 faiFsnfpiAxNn 4.复指数序列njernx)(在 MATLAB 中)**exp(1:0 nwjrxNn 5.指数序列nanx)(在 MATLAB 中naxNn .^1:0 三、实验内容实现和图形生成三、实验内容实现和图形生成1、五种基本函数的生成、五种基本函数的生成程序如下:程序如下: (1)、单位抽样序列、单位抽样序列 做出单位抽样序列以及延时了 5 的单位抽样序列,并对图进行标记说明 注意使用绘图的函数为 stem;标记 xlabel、ylabel、title clc clear n=0:10; x1=[1 zeros(1,10)];x2=[zeros(1,5) 1 zeros(1,5)]; subplot(1,2,1); stem(n,x1); xlabel ('time n'); ylabel('zhenfu'); title('danweichouyangx1'); subplot(1,2,2); stem(n,x2); xlabel('time n');ylabel('zhenfu'); title('yanshi 5');051000.10.20.30.40.50.60.70.80.91time nzhenfudanweichouyangx1051000.10.20.30.40.50.60.70.80.91time nzhenfuyanshi 5((2)) 、单位阶跃序列、单位阶跃序列 clc clear n=0:10; u=[ones(1,11)]; stem(n,u); xlabel('time n'); ylabel('zhenfu'); title('jieyue');01234567891000.10.20.30.40.50.60.70.80.91time nzhenfujieyue((3)正弦函数)正弦函数 x=2*sin(pi*n/6+pi/3); 并对图进行标记说明 clc clear n=1:30; x=2*sin(pi*n/6+pi/3); stem(n,x); xlabel('time n');ylabel('zhenfu'); title('x=2*sin(pi*n/6+pi/3)');051015202530-2-1.5-1-0.500.511.52time nzhenfux=2*sin(pi*n/6+pi/3)(4)、复指数序列、复指数序列 x=2*exp(j*3*n); 并对图进行标记说明 clc clear n=1:30; x=2*exp(j*3*n); stem(n,x); xlabel('time n'); ylabel('zhenfu'); title('x=2*exp(j*3*n)');051015202530-2-1.5-1-0.500.511.52time nzhenfux=2*exp(j*3*n)((5)指数序列)指数序列 x=1.2.^n;并对图进行标记说明 clcclear n=1:30; x=1.2.^n; stem(n,x); xlabel('time n'); ylabel('zhenfu'); title('x=1.2.^n');051015202530050100150200250time nzhenfux=1.2.n2、绘出信号、绘出信号,当,当、、时、时、、、znenx)( 6)12/1 (jz6)12/1 (jz121z、、时的信号实部和虚部图;并对图标记说明,将以上几个图时的信号实部和虚部图;并对图标记说明,将以上几个图62jz6jz 合在一个图里进行显示。
合在一个图里进行显示 clc clear z1=-1/12+j*pi/6; z2=1/12+j*pi/6; z3=1/12;z4=2+j*pi/6; z5=j*pi/6; n=0:20; x1=exp(z1*n); x2=exp(z2*n);x3=exp(z3*n); x4=exp(z4*n);x5=exp(z5*n); subplot(5,2,1); stem(n,real(x1)); xlabel ('time n'); ylabel('shibu'); title('z1=-1/12+j*pi/6 shibu'); subplot(5,2,2);stem(n,imag(x1));xlabel ('time n'); ylabel('xubu'); title('z1=-1/12+j*pi/6 xubu'); subplot(5,2,3); stem(n,real(x2)); xlabel ('time n'); ylabel('shibu'); title('z2=1/12+j*pi/6 shibu'); subplot(5,2,4); stem(n,imag(x2));xlabel ('time n'); ylabel('xubu'); title('z2=1/12+j*pi/6xubu'); subplot(5,2,5); stem(n,real(x3)); xlabel ('time n'); ylabel('shibu'); title('z3=1/12 shibu'); subplot(5,2,6); stem(n,imag(x3));xlabel ('time n'); ylabel('xubu'); title('z3=1/12 xubu'); subplot(5,2,7); stem(n,real(x4)); xlabel ('time n') ;ylabel('shibu'); title('z4=2+j*pi/6 shibu'); subplot(5,2,8); stem(n,imag(x4)); xlabel ('time n'); ylabel('xubu'); title('z4=2+j*pi/6xubu'); subplot(5,2,9); stem(n,real(x5));xlabel ('time n'); ylabel('shibu'); title('z5=j*pi/6 shibu'); subplot(5,2,10); stem(n,imag(x5)); xlabel ('time n'); ylabel('xubu'); title('z5=j*pi/6 xubu');02468101214161820-101time nshibuz1=-1/12+j*pi/6 shibu02468101214161820-101time nxubuz1=-1/12+j*pi/6 xubu02468101214161820-505time nshibuz2=1/12+j*pi/6 shibu02468101214161820-505time nxubuz2=1/12+j*pi/6xubu024681012141618200510time nshibuz3=1/12 shibu02468101214161820-101time nxubuz3=1/12 xubu02468101214161820-202x 1017time nshibuz4=2+j*pi/6 shibu02468101214161820-505x 1017time nxubuz4=2+j*pi/6xubu02468101214161820-101time nshibuz5=j*pi/6 shibu02468101214161820-101time nxubuz5=j*pi/6 xubu3、、绘出信号绘出信号的频率是多少?周期是多少?产生一个数字的频率是多少?周期是多少?产生一个数字)1 . 0*2sin(5 . 1)(nnx频率为频率为 0.9 的正弦序列,并显示该信号,说明其周期的正弦序列,并显示该信号,说明其周期? 并将以上几个图合在一并将以上几个图合在一 个图里进行显示。
个图里进行显示 clcclear n=0:40; x1=1.5*sin(2*pi*0.1*n);x2=sin(0.9*n); subplot(1,2,1); stem(n,x1); xlabel ('time n'); ylabel('zhenfu'); title('x1=1.5*sin(2*pi*0.1*n)'); subplot(1,2,2); stem(n,x2); xlabel ('time n'); ylabel('zhenfu'); title('x2=sin(0.9*n)');0510152025303540-1.5-1-0.500.511.5time nzhenfux1=1.5*sin(2*pi*0.1*n)0510152025303540-1-0.8-0.6-0.4-0.200.20.40.60.81time nzhenfux2=sin(0.9*n)4、使用帮助功能学习、使用帮助功能学习 square(方波方波), sawtooth(锯齿波锯齿波)和和 sinc 函数,并绘图函数,并绘图1)) 、方波绘图程序如下:、方波绘图程序如下: clc clear t=-2*pi:0.001:2*pi; x=square(t); plot(t,x); xlabel('t'),ylabel(' x=square(t)');-8-6-4-202468-1-0.8-0.6-0.4-0.200.20.40.60.81tx=square(t)(2)、三角波绘图程序如下:、三角波绘图程序如下:clc clear t=-2*pi:0.001:2*pi; y=sawtooth(t); plot(t,y); xlabel('t'),ylabel(' y=sawtooth(t);');-8-6-4-202468-1-0.8-0.6-0.4-0.200.20.40.60.81ty=sawtooth(t);((3))sinc 函数绘图程序如下:函数绘图程序如下: clc clear t=-pi:0.001:pi; x=sinc(t); plot(t,x); xlabel('t'),ylabel('sinc(t)');-4-3-2-101234-0.4-0.200.20.40.60.81tsinc(t)。
