数字信号处理 高春仙备课课件版 实验10 离散信号的时域描述与运算.pptx
34页实验10 离散信号的时域描述与运算,实验目的:,1、掌握常用时域离散信号的MATLAB表示方法2、掌握离散信号的基本运算,包括信号相加与相乘,平移,反转,尺度变换,卷积,一、离散时间信号的时域描述,实验原理:,离散时间信号是指在离散时刻才有定义的信号,简称离散信号或者序列离散信号的绘制一般采用stem函数,MATLAB只能表示一定时间范围内有限长度的序列,而对于无限长序列,只能在一定范围内表示出来,常用离散信号的MATLAB表示,1、单位阶跃信号,function f = u(n)f = (n=0) ;,2、单位冲激信号,function f = delta(n) f = (n=0) ;,clear allx = -3:5 ;y1 = u(x) ;y2 = delta(x) ;subplot(2,1,1)stem(x,y1,fill) ;xlabel(n) ;grid on ;axis(-3 5 -0.1 1.1) ;subplot(2,1,2)stem(x,y2,fill) ;xlabel(n) ;grid on ;axis(-3 5 -0.1 1.1) ;,3、矩形序列,clear allx = -2:8 ;y = u(x) - u(x-4) ;stem(x,y,fill) ;xlabel(n) ;grid onaxis(-2 8 -0.1 1.1) ;,4、单边指数序列,n = 0:10 ;a1 = 1.2 ; a2= -1.2 ; a3 = 0.8 ; a4 = -0.8 ;f1 = a1.n ; f2 = a2.n ;f3 = a3.n ; f4 = a4.n ;subplot(2,2,1)stem(n,f1,fill) ;xlabel(n) ;grid on ;,从实验图可知,当 时,单边指数序列发散;,当 时,单边指数序列收敛;,从实验图可知,当 时,单边指数序列取正值;,当 时,单边指数序列在正负之间摆动,5、正弦序列,clear alln = 0:39 ;f = sin(pi/17*n) ;stem(n,f,fill) ;xlabel(n) ;grid on ;axis(0 40 -1.2 1.2) ;,6、复指数序列,n = 0:30 ;A=2 ; a = -0.1 ; b = pi/5 ;f = A*exp(a+j*b)*n) ;subplot(2,2,1); stem(n,real(f),fill) ; xlabel(n) ; title(实部) ; grid on ;subplot(2,2,2); stem(n,imag(f),fill) ; xlabel(n) ; title(虚部) ; grid on ;subplot(2,2,3); stem(n,abs(f),fill) ; xlabel(n) ; title(模) ; grid on ;subplot(2,2,4); stem(n,angle(f),fill) ; xlabel(n) ; title(相角) ; grid on ;,二、离散时间信号基本运算,序列的平移、反转,序列的平移、反转在MATLAB中的实现同连续信号,可以用变量替换来实现,同时序列的反转还可以用MATLAB中的函数fliplr实现。
例1:,a = 0.8 ; N = 8 ;n = -12:12 ;f1 = a.n ; f2 = u(n)-u(n-N) ; x1 = f1.*f2 ;n1 = n ;n2 = n1-3 ;n3 = n1+2 ;n4 = -n1 ;subplot(4,1,1)stem(n1,x1,fill) ; grid on; title(x1(n) ; axis(-15 15 0 1) ;subplot(4,1,2)stem(n2,x1,fill) ; grid on; title(x2(n) ; axis(-15 15 0 1) ;subplot(4,1,3)stem(n3,x1,fill) ; grid on; title(x3(n) ; axis(-15 15 0 1) ;subplot(4,1,4)stem(n4,x1,fill) ; grid on; title(x4(n) ; axis(-15 15 0 1) ;,n = -12:12 ;x1=x_f(n);x2=x_f(n+3);x3=x_f(n-2);x4=x_f(-1*n);subplot(4,1,1); stem(n,x1,filled); grid on; title(x1(n) ; axis(-15 15 0 1) ;subplot(4,1,2); stem(n,x2,filled) ; grid on; title(x2(n) ; axis(-15 15 0 1) ;subplot(4,1,3); stem(n,x3,filled) ; grid on; title(x3(n) ; axis(-15 15 0 1) ;subplot(4,1,4); stem(n,x4,filled) ; grid on; title(x4(n) ; axis(-15 15 0 1) ;,function f = x_f(n)a = 0.8 ; N = 8 ;f1 = a.n ;f2 = u(n)-u(n-N) ;f = f1.*f2 ;,序列的尺度变换,序列的尺度变换是由序列 得到 ,对应着抽取和插值。
当 ,每隔 个序列值抽取一个值;当 ,每两个序列值之间插入 零值,例2:,clf ;n = 0:49 ;x = sin(2*pi*0.12*n) ;y = zeros(1,3*length(x) ;y(1:3:length(y) = x ;subplot(2,1,1)stem(n,x,.);subplot(2,1,2)m = 0:3*length(x)-1 ;stem(m,y,.);,例3:,clf ;n = 0:49 ;m = 0:floor(50/3) -1;x = sin(2*pi*0.042*n) ;y = zeros(1,length(m) ;y = x(1:3:3*floor(50/3);%抽取subplot(2,1,1)stem(n,x,.);subplot(2,1,2)stem(m,y,.);,序列的相加与相乘,对应离散样点值的加减乘除,因此与连续时间信号的数值处理方法一致,例3:,n = -3:5 ;f1 = u(n) - u(n-4) ;f2 = 2.(-n) ;x1 = f1 + f2 ;x2 = f1 - f2 ;x3 = f1.*f2 ;,function f,n = sigmult(f1,n1,f2,n2)% 序列相乘n = min(min(n1),min(n2):max(max(n1),max(n2) ;x1 = zeros(1,length(n) ;x2 = x1 ;x1(find(n=min(n1),function f,n = sigadd(f1,n1,f2,n2)% 序列相加n = min(min(n1),min(n2):max(max(n1),max(n2) ;x1 = zeros(1,length(n) ;x2 = x1 ;x1(find(n=min(n1),clfn1 = -5:5 ;f1 = u(n1)-u(n1-4) ;n2 = -3:5 ;f2 = 2.(-n2) ;f3,n3 = sigadd(f1,n1,f2,n2) ;f4,n4 = sigmult(f1,n1,f2,n2) ;subplot(211)stem(n3,f3,fill) ;xlabel(n)title(f1+f2) ;subplot(212)stem(n4,f4,fill) ;xlabel(n)title(f1*f2) ;,序列的卷积,直接用conv函数求解,注意:用MATLAB进行卷积和运算时,无法实现无限的累加,只能计算时限信号的卷积和,同时应注意序列长度的变化,实验内容:,1、利用MATLAB命令画出下列序列的波形图 (1) (2) (3),2、利用MATLAB命令画出下列序列的实部、虚部、模与相角,3、已知信号 ,试用MALTAB命令画出下列信号的波形图 (1) (2),4、已知LTI系统的单位序列响应h(n)与激励x(n)分别如图所示,求系统的零状态响应并绘出时域波形,实验报告要求:,1、简述实验目的和实验原理2、编程实现实验内容,要求附上源程序3、总结实验中的主要结论、收获和体会,。





