信号系统MATLAB实验报告

  • 格式:doc
  • 大小:290.50 KB
  • 文档页数:31

信号与系统实验报告桂林理工大学信息科学与工程学院 电子信息工程实验二 信号及其表示【实验目的】了解各种常用信号的表达方式 掌握部分绘图函数 【实验内容】一、绘出连续时间信号x(t)=te707.0 sin32t 关于t 的曲线,t 的范围为 0~30s ,并以0.1s 递增。

MATLAB 源程序为:t=0:0.1:30; %对时间变量赋值x=exp(-0.707*t).*sin(2/3.*t); %计算变量所对应得函数值 plot(t,x);grid; %绘制函数曲线 ylabel('x(t)');xlabel('Time(sec)')二、产生周期为0.02的方波。

MATLAB源程序为:Fs=100000;t=0:1/Fs:1;x1=square(2*pi*50*t,20);x2=square(2*pi*50*t,80);subplot(2,1,1),plot(t,x1),axis([0,0.2,-1.5,1.5]); subplot(2,1,2),plot(t,x2),axis([0,0.2,-1.5,1.5]);三、产生sinc(x)函数波形。

MATLAB源程序为:x=linspace(-4,4);y=sinc(x);plot(x,y)四、绘制离散时间信号的棒状图。

其中x(-1)=-1,x(0)=1,x(1)=2,x(2)=1,x(3)=0,x(4)=-1,其他时间x(n)=0。

MATLAB源程序为:n=-3:5; %定位时间变量x=[0,0,-1,1,2,1,-1,0,0];stem(n,x);grid; %绘制棒状图line([-3,5],[0,0]); %画X轴线xlabel('n');ylabel('x[n]')五、单位脉冲序列 δ(n-0n )={00...1...0n n n n =≠直接实现:x=zeros(1,N);x(1,n0)=1;函数实现:利用单位脉冲序列)(0n n -δ的生成函数impseq,即 function[x,n]=impseq(n0,ns,nf) n=[ns:nf];x=[(n-n0)==0]; plot(n,x); stem(n,x);输入参数:impseq(0,0,9)——连续图形12345678900.10.20.30.40.50.60.70.80.91输入参数:impseq(0,0,9)——离散图形六、单位阶跃序列ε(n-0n )={00...1...0n n n n ≥<直接实现:n=[ns:nf];x=[(n-n0)>=0];函数实现:利用单位阶跃序列)(0n n -ε的生成函数stepseq ,即 Function[x,n]=stepseq(n0,ns,nf) n=[ns:nf];x=[(n-n0)>=0]; plot(n,x);七、实指数序列 R a n a n x n∈∀=,,)( 直接实现:n=[ns:nf]:x=a.^n;函数实现:利用实指数序列na n x =)(的生成函数rexpseq,即 Function[x,n]=rexpseq(a,ns,nf) n=[ns:nf];x=a,^n:八、复指数序列 n e n x n j ∀=+,)()(ωδ直接实现:n=[ns:nf];x=exp((sigema+jw)*n); 函数实现:利用复指数序列nj en x )()(ωδ+=的生成函数cexpseq,即Function[x,n]=cexpseq(sigema,w,ns,nf) n=[ns:nf];x=exp((sigema+j*w)*n);0123456789-3000-2000-10000100020003000400050006000九、正(余)弦序列 n wn n x ∀+=),cos()(θ直接实现:n=[ns:nf];x=cos(w*n+sita);函数实现:利用正(余)弦序列x(n)=cos(wn+θ)的生成函数cosswq,即 Function[x,n]=cosseq(w,ns,nf,sita) n=[ns:nf];x=cos(w*n+sita);输入参数:cosseq(3.14,0,9,30)——连续信号0123456789-0.2-0.15-0.1-0.0500.050.10.150.2输入参数:cosseq(3.14,0,9,30)——离散信号0123456789实验三信号的运算【实验目的】了解信号处理的基本操作。

熟悉一些常用的序列及其应用。

掌握编写MATLAB函数进行一些常用运算。

【实验内容】一、信号的相加与相乘MATLAB源程序为:n1=[5:4]; %序列x1(n)的时间起始及终止位置n1s=-5;n1f=4;x1=[2,3,1,-1,3,4,2,1,-5,-3]; %序列x1(n)不同时间的幅度n2=[0:9]; %序列x2(n)的时间起始及终止位置n2s=0;n2f=9;x2=[1,1,1,1,1,1,1,1,1,1]; %序列x2(n)不同时间的幅度ns=min(n1s,n2s);nf=max(n1f,n2f); %求取新信号的时间起始及终止位置n=ns:nf;y1=zeros(1,length(n)); %延拓序列初始化y2=zeros(1,length(n));y1(find((n>=n1s)&(n<=n1f)==1))=x1; %给延拓序列y1赋值x1y2(find((n>=n2s)&(n<=n2f)==1))=x2; %给延拓序列y2赋值x2ya=y1+y2; %逐点相加yp=y1.*y2; %逐点相乘subplot(4,1,1),stem(n,y1,'.');line([n(1),n(end)],[0,0]);ylabel('x1(n)'); %画x轴subplot(4,1,2),stem(n,y2,'.');line([n(1),n(end)],[0,0]);ylabel('x2(n)');subplot(4,1,3),stem(n,ya,'.');line([n(1),n(end)],[0,0]);ylabel('x1(n)+x2(n)');subplot(4,1,4),stem(n,yp,'.');line([n(1),n(rnd)],[0,0]);ylabel('x1(n).x2(n)');二、序列移位与周期延拓序列移位的数学描述为:y(n)=x(n-m)。

序列移位的METLAB 实现:y=x;ny=nx-m 。

序列周期延拓的数学描述为))(()(n x n y M= ,其中M 表示延拓周期。

序列周期延拓的MA TLAB 实现:ny=nxs:nxf;y=x(mod(ny,M)+1)。

MATLAB 源程序为: N=24;M=8;m=3; n=0:N-1;x1=(0.8).^n; %生成指数序列x2=[(n>=0)&(n<M)]; %形成矩形序列)(n R M x=x1.*x2; %截取操作形成新序列x(n) xm=zeros(1,N); for k=m+1:m+Mxm(k)=x(k-m); %产生序列移位x(n-3)endxc=x(mod(n,M)+1); %产生x(n)的周期延拓8))((n x xcm=x(mod(n-m,M)+1); %产生移位序列x(n-3)的周期延拓8))3((-n x subplot(4,1,1),stem(n,x,'.');ylabel('x(n)'); subplot(4,1,2),stem(n,xm,'.');ylabel('x(n-3)'); subplot(4,1,3),stem(n,xc,'.');ylabel('x((n))_8'); subplot(4,1,4),stem(n,xcm,'.');ylabel('x((n-3))_8');三、序列反转与序列累加运算序列反转的数学描述为:y(n)=x(-n)。

序列反转的METLAB可由函数fliplr来实现。

该函数的功能将行向量左右翻转,其调用格式:y=fliplr(x)。

序列累加的数学描述为:y(n)=∑)(i x。

序列累加的MATLAB实现可由函数cumsum 来实现,调用格式为:y=cumsum(x)。

例、求序列x(n)=3e n2.0-的反转序列y(n)=x(-n),MATLAB源程序为:n=0:10; %x(n)序列的时间序列x=3*exp(-0.2*n); %x(n)序列大小y=fliplr(x); %x(n)序列反转n1=-fliplr(n); %时间序列的反转(反转点为原点)n2=fliplr(-(n-3)); %在指定位置m=3处的时间序列的反转subplot(2,1,1);stem(n,x); %绘制x(n)序列xlabel('n'),ylabel('x(n)');subplot(2,1,2);stem(n1,y); %绘制反转y(n)=x(-n)序列xlabel('n'),ylabel('y(n)=x(-n)');s=cumsum(x); %求累加序列s(n)figure(2);subplot(2,1,1);stem(n2,y); %绘制点为3处的反转序列y(n)=x(-n+3)xlabel('n'),ylabel('y(n)=x(-n+3)');subplot(2,1,2);stem(n,s); %绘制s(n)序列xlabel('n'),ylabel('s(n)');四、两序列的卷积运算两序列的卷积运算的数学描述为:y(n)=x 1(n)*x 2(n)=)()(21m n m x x m-∑两序列的卷积运算的MA TLAB 实现:y=conv(x1,x2)。

序列x1(n)和x2(n)必须长度有限。

例、计算下列卷积,并图示各序列及卷积结果。

)()(),()(),(*)()(1012011119.0n n n n n n n R h Rx h x y n===;).(),5()(),(*)()(10220522229.0n n n n n n R h Rx h x y n =-==-MATLAB 源程序如下:Nx=20;Nh=10;m=5; %设定Nx,Nh 和位移值m n=0:Nx-1;x1=(0.9).^n; %产生x1(n) x2=zeros(1,Nx+m);for k=m+1:m+Nx %产生x2(n)=x1(n-m) x2(k)=x1(k-m) %完成位移 endnh=0:Nh-1;h1=ones(1,Nh); %产生h1(n) h2=h1;y1=conv(x1,h1); %计算y1(n)=x1(n)*h1(n) y2=conv(x2,h2); %计算y2(n)=x2(n)*h2(n) x2 =0 0 0 0 0 1 0 0 0 0 0 0 0 0Columns 15 through 250 0 0 0 0 0 0 0 0 0 0x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0Columns 9 through 160 0 0 0 0 0 0 0Columns 17 through 240 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160 0 0 0 0 0 0 00 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0 0 0 0 0 0 0Columns 17 through 240 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0 0 0 0 0 00 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0 0 0 0 0Columns 17 through 240 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0 0 0 00 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0 0 0Columns 17 through 240 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0 00 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0Columns 17 through 240 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.34870 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.3487Columns 17 through 240.3138 0 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.34870.3138 0.2824 0 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.3487Columns 17 through 240.3138 0.2824 0.2542 0 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.34870.3138 0.2824 0.2542 0.2288 0 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.3487Columns 17 through 240.3138 0.2824 0.2542 0.2288 0.2059 0 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.34870.3138 0.2824 0.2542 0.2288 0.2059 0.1853 0 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.3487Columns 17 through 240.3138 0.2824 0.2542 0.2288 0.2059 0.1853 0.1668 0Column 25x2 =Columns 1 through 80 0 0 0 0 1.0000 0.9000 0.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.3874 0.34870.3138 0.2824 0.2542 0.2288 0.2059 0.1853 0.16680.1501Column 250 x2 =Columns 1 through 80 0 0 0 0 1.0000 0.90000.8100Columns 9 through 160.7290 0.6561 0.5905 0.5314 0.4783 0.4305 0.38740.3487Columns 17 through 240.3138 0.2824 0.2542 0.2288 0.2059 0.1853 0.16680.1501Column 250.1351实验四 连续系统的时域分析【实验目的】进一步熟悉系统在MATLAB 中的表示 掌握利用卷积求系统的响应【实验内容】一、连续LTI 系统的响应在连续时间情况下,系统对任意输入信号x(t)的响应(即系统的输出)为y(t)=T[x(t)],则y(t)为系统输入与系统单位冲激响应的卷积积分,即y(t)= T[x(t)]=x(t)*h(t)=τττd t h x )()(-⎰+∞∞-例:某LTI 系统的单位冲激响应tet h 1.0)(-=,输入x(t)={101....1.....0≤≤t 其他,初始条件为零,求系统的响应y(t)。