东南大学信号与系统MATLAB实践第一次作业

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

信号与系统MATLAB实践练习一实验一二.熟悉简单的矩阵输入1.实验代码A=[1,2,3;4,5,6;7,8,9]实验结果A=1234567893.实验代码B=[9,8,7;6,5,4;3,2,1]C=[4,5,6;7,8,9;1,2,3]实验结果:B=987654321C=4567891234.AA=123456789BB=987654321CC=456789123三.基本序列运算1.A=[1,2,3],B=[4,5,6]A=123B=456C=A+BC=579D=A-BD=-3-3-3E=A.*BE=41018F=A./BF=0.25000.40000.5000G=A.^BG=132729stem(A)stem(B)11.21.41.61.822.22.42.62.830123456stem(C)11.21.41.61.822.22.42.62.830123456789stem(D)11.21.41.61.822.22.42.62.83-3-2.5-2-1.5-1-0.50stem(E)11.21.41.61.822.22.42.62.83024681012141618stem(F)11.21.41.61.822.22.42.62.8300.050.10.150.20.250.30.350.40.450.5stem(G)11.21.41.61.822.22.42.62.830100200300400500600700800再举例:a=[-1,-2,-3]a=-1-2-3b=[-4,-5,-6]b=-4-5-6c=a+bc=-5-7-9d=a-bd=333e=a.*be=41018f=a./bf=0.25000.40000.5000g=a.^bg=1.0000-0.03130.0014stem(a)11.21.41.61.822.22.42.62.83-3-2.5-2-1.5-1-0.50stem(b)11.21.41.61.822.22.42.62.83-6-5-4-3-2-10stem(c)11.21.41.61.822.22.42.62.83-9-8-7-6-5-4-3-2-10stem(d)11.21.41.61.822.22.42.62.8300.511.522.53stem(e)11.21.41.61.822.22.42.62.83024681012141618stem(f)11.21.41.61.822.22.42.62.8300.050.10.150.20.250.30.350.40.450.5stem(g)11.21.41.61.822.22.42.62.83-0.200.20.40.60.811.22.t=0:0.001:10f=5*exp(-t)+3*exp(-2*t);plot(t,f)ylabel('f(t)');xlabel('t');title('(1)');t=0:0.001:3;f=(sin(3*t))./(3*t);plot(t,f)ylabel('f(t)');xlabel('t');title('(2)');k=0:1:4;f=exp(k);stem(f)11.522.533.544.550102030405060四.利用MATLAB求解线性方程组2.A=[1,1,1;1,-2,1;1,2,3]b=[2;-1;-1]x=inv(A)*bA=1111-21123b=2-1-1x=3.00001.0000-2.00004.A=[2,3,-1;3,-2,1;1,2,1]b=[18;8;24]x=inv(A)*bA=23-13-21121b=18824x=468实验二二.1.k=0:50x=sin(k);stem(x)xlabel('k');ylabel('sinX');title('sin(k)ε(k)');2.k=-25:1:25x=sin(k)+sin(pi*k);stem(k,x)xlabel('k');ylabel('f(k)');title('sink+sinπk');3.k=3:50x=k.*sin(k);stem(k,x)xlabel('k');ylabel('f(k)');title('ksinkε(k-3)');4.%函数functiony=f1(k)ifk0y=(-1)^k;elsey=(-1)^k+(0.5)^k;end%运行代码fork=-10:1:10;y4(k+11)=f1(k);endk=-10:1:10;stem(k,y4);xlabel('k');ylabel('f(k)');title('4');七.2.f1=[1111];f2=[321];conv(f1,f2)ans=3566313.函数定义:function[r]=pulse(k)ifk0r=0;elser=1;endend运行代码fork=1:10f1(k)=pulse(k);f2(k)=(0.5^k)*pulse(k);endconv(f1,f2)结果ans=Columns1through100.50000.75000.87500.93750.96880.98440.99220.99610.99800.9990Columns11through200.99950.99980.99990.99991.00001.00001.00001.00001.00001.0000Columns21through300.50000.25000.12500.06250.03120.01560.00780.00390.00200.0010Columns31through390.00050.00020.00010.00010.00000.00000.00000.00000.00004fori=1:10f1(i)=pulse(i);f2(i)=((-0.5)^i)*pulse(i);endconv(f1,f2)结果ans=Columns1through10-0.5000-0.2500-0.3750-0.3125-0.3438-0.3281-0.3359-0.3320-0.3340-0.3330Columns11through20-0.3325-0.3323-0.3322-0.3321-0.3321-0.3320-0.3320-0.3320-0.3320-0.3320Columns21through300.1680-0.08200.0430-0.01950.0117-0.00390.0039-0.00000.00200.0010Columns31through390.00050.00020.00010.00010.00000.00000.00000.00000.0000实验三2.clear;x=[1,2,3,4,5,6,6,5,4,3,2,1];N=0:11;w=-pi:0.01:pi;m=length(x);n=length(w);fori=1:nF(i)=0;fork=1:mF(i)=F(i)+x(k)*exp(-1j*w(i)*k);endendF=F/10;subplot(2,1,1);plot(w,abs(F),'b-');xlabel('w');ylabel('F');title('幅度频谱');gridsubplot(2,1,2);plot(w,angle(F),'b-');xlabel('w');X=fftshift(fft(x))/10;subplot(2,1,1);holdon;plot(N*2*pi/12-pi,abs(X),'r.');legend('DIFT算法','DFT算法');subplot(2,1,2);holdon;plot(N*2*pi/12-pi,angle(X),'r.');xlabel('w');ylabel('相位');title('相位频谱');grid三.1.%fun1.mfunctiony=fun1(x)if((-pix)&&(x0))y=pi+x;elseif((0x)&&(xpi))y=pi-x;elsey=0end%new.mclearallclcfori=1:1000g(i)=fun1(2/1000*i-1);w(i)=(i-1)*0.2*pi;endfori=1001:10000g(i)=0;w(i)=(i-1)*0.2*pi;endG=fft(g)/1000;subplot(1,2,1);plot(w(1:50),abs(G(1:50)));xlabel('w');ylabel('G');title('DFT幅度频谱');subplot(1,2,2);plot(w(1:50),angle(G(1:50)))xlabel('w');ylabel('Fi');title('DFT相位频谱');01020304000.511.522.53wGDFT幅度频谱010203040-3.5-3-2.5-2-1.5-1-0.50wFiDFT相位频谱2.%fun2.mfunctiony=fun2(x)ifx1&&x-1y=cos(pi*x/2);elsey=0;end%new2.mfori=1:1000g(i)=fun2(2/1000*i-1);w(i)=(i-1)*0.2*pi;endfori=1001:10000g(i)=0;w(i)=(i-1)*0.2*pi;endG=fft(g)/1000;subplot(1,2,1);plot(w(1:50),abs(G(1:50)));xlabel('w');ylabel('G');title('幅度频谱');subplot(1,2,2);plot(w(1:50),angle(G(1:50)))xlabel('w');ylabel('Fi');title('相位频谱');01020304000.10.20.30.40.50.60.7wGDFT幅度频谱010203040-4-3-2-10123wFiDFT相位频谱3.%fun3.mfunctiony=fun3(x)ifx0&&x-1y=1;elseifx0&&x1y=-1;elsey=0end%new.mfori=1:1000g(i)=fun3(2/1000*i-1);w(i)=(i-1)*0.2*pi;endfori=1001:10000g(i)=0;w(i)=(i-1)*0.2*pi;endG=fft(g)/1000;subplot(1,2,1);plot(w(1:50),abs(G(1:50)));xlabel('w');ylabel('G');title('DFT幅度频谱');subplot(1,2,2);plot(w(1:50),angle(G(1:50)))xlabel('w');ylabel('Fi');title('DFT相位频谱');01020304000.10.20.30.40.50.60.70.8wGDFT幅度频谱010203040-4-3-2-10123wFiDFT相位频谱练习二实验六一.用MATLAB语言描述下列系统,并求出极零点、1.Ns=[1];Ds=[1,1];sys1=tf(Ns,Ds)实验结果:sys1=1-----s+1[z,p,k]=tf2zp([1],[1,1])z=Emptymatrix:0-by-1p=-1k=12.Ns=[10]Ds=[1,-5,0]sys2=tf(Ns,Ds)实验结果:Ns=10Ds=1-50sys2=10---------s^2-5s[z,p,k]=tf2zp([10],[1,-5,0])z=Emptymatrix:0-by-1p=05k=10二.已知系统的系统函数如下,用MATLAB描述下列系统。1.z=[0];p=[-1,-4];k=1;sys1=zpk(z,p,k)实验结果:sys1=s-

1 / 86
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功