《基于MATLAB的信号与系统实验指导》编程练习_第1页
《基于MATLAB的信号与系统实验指导》编程练习_第2页
《基于MATLAB的信号与系统实验指导》编程练习_第3页
《基于MATLAB的信号与系统实验指导》编程练习_第4页
《基于MATLAB的信号与系统实验指导》编程练习_第5页
已阅读5页,还剩35页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、2连续时间信号在MATLAB中的表示2-1.利用MATLAB命令画出下列连续信号的波形图(1)>> t=0:0.01:3;>> ft=2*cos(3*t+pi/4);>> plot(t,ft),grid on;>> axis(0 3 -2.2 2.2);>> title('2cos(3t+pi/4)')(2)>> t=0:0.01:3;>> ft=2-exp(-t);>> plot(t,ft),grid on;>> title('(2-exp(-t)u(t)

2、9;)(3)>> t=-1:0.01:1;>> ft=t.*(uCT(t)-uCT(t-1);>> plot(t,ft),grid on>> axis(-1 1 -0.2 1.2);>> title('tu(t)-u(t-1)')(4)>> t=-1:0.01:3;>> ft=(1+cos(pi*t).*(uCT(t)-uCT(t-2);>> plot(t,ft),grid on>> axis(-1 3 -0.2 2.2);>> title('1+co

3、s(pi*t)u(t)-u(t-2)')2-2.利用MATLAB命令画出下列复信号的实部、虚部、模和辐角(1)>> t=0:0.01:3;>> ft=2+exp(i*(pi/4)*t)+exp(i*(pi/2)*t);>> subplot(2,2,1);plot(t,real(ft);title('实部');axis(0 3 0 4);grid on;>> subplot(2,2,2);plot(t,imag(ft);title('虚部');axis(0 3 0 2);grid on;>> su

4、bplot(2,2,3);plot(t,abs(ft);title('模');axis(0 3 0 4);grid on;>> subplot(2,2,4);plot(t,angle(ft);title('相角');axis(0 3 0 2);grid on;(2)t=0:0.01:3;>> ft=2*exp(i*(t+pi/4);>> subplot(2,2,1);plot(t,real(ft);title('实部');axis(0 3 0 2);grid on;>> subplot(2,2,2)

5、;plot(t,imag(ft);title('虚部');axis(0 3 0 2);grid on; >> subplot(2,2,3);plot(t,abs(ft);title('模');axis(0 3 0 4);grid on;>> subplot(2,2,4);plot(t,angle(ft);title('相角');axis(0 3 0 4);grid on;2-3.利用MATLAB命令产生幅度为1、周期为1、占空比为0.5的一个周期矩形脉冲信号>> t=-0.5:0.01:3;>> f

6、t=square(2*pi*t,50);>> plot(t,ft);grid on;axis(-0.5 3 -1.2 1.2);>> title('幅度为1、周期为1、占空比0.5的周期举行脉冲信号')3连续时间信号在MATLAB中的运算3-1.试用MATLAB命令绘出以下信号的波形图(1)>> syms x t;>> t=-1:0.01:1;>> x=exp(-t).*sin(10*pi*t)+exp(-0.5*t).*sin(9*pi*t);>> plot(t,x)(2)>> syms x

7、t;>> t=-1:0.01:1;>> x=sinc(t).*cos(10*pi*t);>> plot(t,x)3-2.已知连续时间信号f(t)的波形如图3-6所示,试用MATLAB命令画出下列信号的波形图先画出图3-6:>> t=-2:0.01:2;>>f=(-t-1).*(-uCT(t+2)+uCT(t+1)+uCT(t+1)+uCT(t)-uCT(t-1)-(t-1).*(uCT(t-1)-uCT(t-2)-uCT(t-2);>> plot(t,f)>> axis(-4 4 -1 2)>> t

8、itle('图3-6')>> t=-2:0.01:2;>> f1=funct2(t-1);>> f2=funct2(2-t);>> f3=funct2(2*t+1);>> f4=funct2(4-t/2);>> f5=(funct2(t)+funct2(-t).*uCT(t);>> subplot(231);plot(t,f1);grid on;title('f(t-1)');axis(-3 3 -1 2);>> subplot(232);plot(t,f2);gri

9、d on;title('f(2-t)');axis(-3 3 -1 2);>> subplot(233);plot(t,f3);grid on;title('f(2t-1)');axis(-3 3 -1 2);>> subplot(234);plot(t,f4);grid on;title('f(4-t/2)');axis(-3 3 -1 2);>> subplot(235);plot(t,f5);grid on;title('(f(t)+f(-t)u(t)');axis(-3 3 -1 2);

10、3-3.试用MATLAB命令绘出如图3-7所示信号的偶分量和奇分量>> t=0:0.01:2;>> f=(uCT(t)-uCT(t-2).*(-t+1);>> plot(t,f);title('图3-7')>> f1=fliplr(f);>> fe=(f+f1)/2;fo=(f-f1)/2;>> subplot(211),plot(t,fe);grid on>> title('fe')>> subplot(212),plot(t,fo);grid on;title(&

11、#39;fo')4连续时间信号的卷积计算4-1用MATLAB命令绘出下列信号的卷积积分f1t*f2(t)的时域波形图>> dt=0.001;t1=-0.5:dt:3.5;>> f1=uCT(t1)-uCT(t1-2);>> t2=t1;>> f2=uCT(t2)+uCT(t2-1)-uCT(t2-2)-uCT(t2-3);>> t,f=ctsconv(f1,f2,t1,t2,dt);6周期信号的傅里叶级数及频谱分析6-1已知周期三角信号如图6-5所示,试求出该信号的傅里叶级数,利用MATLAB编程实现其各次谐波的叠加,并验证其

12、收敛性。6-2 试用MATLAB分析图6-5中周期三角信号的频谱。当周期三角信号的周期和三角信号的宽度变化时,试观察分析其频谱的变化。7 傅里叶变换及其性质7-1试用MATLAB命令求下列信号的傅里叶变换,并绘出其幅度谱和相位谱。(1)f1t=sin2(t-1)(t-1) (2)f2t=sin(t)t2解:(1)ft1=sym('sin(2*pi*(t-1)/(pi*(t-1)');>> Fw1=simplify(fourier(ft1);>> subplot(211)>> ezplot(abs(Fw1),grid on>> ti

13、tle('幅度谱')>> phase=atan(imag(Fw1)/real(Fw1);>> subplot(212)>> ezplot(phase);grid on>> title('相位谱')(2)7-2.试用MATLAB命令求下列信号的傅里叶反变换,并绘出其时域信号图。(1)F1w=103+wi-45+wi (2)F2w=e-4w2解:(1)>> syms t>> Fw=sym('10/(3+w*i)-4/(5+w*i)');>> ft=ifourier(F

14、w,t);>> ezplot(ft),grid on(2)>> syms t>> Fw2=sym('exp(-4*w2)');>> ft2=ifourier(Fw2,t) ft2 = exp(-t2/16)/(4*pi(1/2)3.试用MATLAB数值计算方法求图7-8所示信号的傅里叶变换,并画出其频谱图。解:4.已知两个门信号的卷积为三角波信号,试用MATLAB命令验证傅里叶变换的时域卷积定理。解:将门函数先进行时域卷积运算,再将卷积后的结果做傅里叶变换,程序和结果如下:dt = 0.01; t&#

15、160;= -2:dt:2.5;f1 = uCT(t+0.5)- uCT(t-0.5); f = conv(f1,f1)*dt;ft=sym('f'); Fw = fourier(ft) Fw =2*i*pi*dirac(1,w)  将一个门函数先进行傅里叶变换,再将结果与自身相乘,程序和结果如下:dt = 0.01; t = -2:dt:2.5; f1 = u

16、CT(t+0.5)- uCT(t-0.5); ft=sym('f1'); Fw = fourier(ft); Fw=Fw*Fw Fw =-4*pi2*dirac(1,w)2 由此来验证傅里叶变换的时域卷积定理第8章 连续时间LTI系统的频率特性及频域分析8.1试用MATLAB命令求图8-8所示电路系统的幅频特性和相频特性。已知R=10,L=2H,C=0.1F解:由电路知识可得,该电路系统的频率响应为H=j0.2(j)3+0.2(j)2+jMATLAB源程序:>> w=-6*pi

17、:0.01:6*pi;>> b=1 0;>> a=0.2 0.2 1 0;>> H=freqs(b,a,w);>> subplot(211)>> plot(w,abs(H),grid on>> xlabel('omega(rad/s)'),ylabel('|H(omega)|')>> title('电路系统的幅频特性')>> subplot(212)>> plot(w,angle(H),grid on>> xlabel('

18、;omega(rad/s)'),ylabel('phi(omega)')>> title('电路系统的相频特性')8.2已知系统微分方程和激励信号如下,试用MATLAB命令求系统的稳态响应。(1)dy(t)dt+32yt=df(t)dt,ft=cos2t;(2)d2y(t)dt2+2dy(t)dt+3yt=-dftdt+2f(t),ft=3+cos2t+cos5t。解:(1)频率响应为H=jj+32>> t=0:0.01:20;>> H=(w*i)/(w*i+3/2);>> f=cos(2*t);>&

19、gt; y=abs(H)*cos(2*t+angle(H);>> subplot(211)>> plot(t,f),grid on>> ylabel('f(t)'),xlabel('Time(s)')>> title('激励信号的波形')>> subplot(212)>> plot(t,y),grid on>> ylabel('y(t)'),xlabel('Time(s)')>> title('稳态响应的波形&#

20、39;)(2)频率响应为H=-j+2(j)2+2j+3MATLAB源程序:>> t=0:0.01:20;>> w1=2;w2=5;>> H1=(-i*w1+2)./(i*w1)2+2*i*w1+3);>> H2=(-i*w2+2)./(i*w2)2+2*i*w2+3);>> f=3+cos(2*t)+cos(5*t);>> y=3+abs(H1)*cos(w1*t+angle(H1)+abs(H2)*cos(w2*t+angle(H2);>> subplot(211);>> plot(t,f);gr

21、id on>> ylabel('f(t)'),xlabel('Time(s)')>> title('激励信号的波形')>> subplot(212);>> plot(t,y),grid on>> ylabel('y(t)'),xlabel('Time(s)')>> title('稳态响应的波形')第9章 信号抽样及抽样定理9.1设有三个不同频率的正弦信号,频率分别为f1=100Hz,f2=200Hz,f3=3800Hz。现在用抽

22、样频率fs=4000Hz对这三个正弦信号进行抽样,用MATLAB命令画出各抽样信号的波形及其频谱,并分析其频率混叠现象。解:>> Ts=0.00025;>> dt=0.0001;>> t1=-0.1:dt:0.1;>> ft=sin(200*pi*t1);>> subplot(221)>> plot(t1,ft),grid on>> axis(-0.01 0.01 -1.1 1.1)>> xlabel('Time(sec)'),ylabel('f(t)')>&g

23、t; title('f1信号')>> N=100;>> k=-N:N;>> W=pi*k/(N*dt);>> Fw=ft*exp(-i*t1'*W)*dt;>> subplot(222)>> plot(W,abs(Fw),grid on>> axis(-5000 5000 -0.1 0.2)>> t2=-0.1:Ts:0.1;>> fst=sin(200*pi*t2);>> subplot(223)>> plot(t1,ft,':&

24、#39;),hold on>> stem(t2,fst),grid on>> axis(-0.01 0.01 -1.1 1.1)>> xlabel('Time(sec)'),ylabel('fs(t)')>> title('抽样后的信号'),hold off>> Fsw=fst*exp(-i*t2'*W)*Ts;>> subplot(224)>> plot(W,abs(Fsw),grid on>> axis(-5000 5000 -0.1 0.

25、2)>> xlabel('omega'),ylabel('Fs(w)')>> title('抽样信号的频谱')9.2结合抽样定理,用MATLAB编程实现Sa(t)信号经冲激脉冲抽样后得到的抽样信号fs(t)及其频谱,并利用fs(t)重构Sa(t)信号。解:首先,画出Sa(t)信号的波形和频谱:>> syms t;>> Sa(t)=(sin(t)/t;>> subplot(211)>> ezplot(Sa(t),grid on>> xlabel('Time(

26、sec)'),ylabel('Sa(t)')>> title('Sa(t)的波形')>> Fw=simplify(fourier(Sa(t);>> subplot(212)>> ezplot(abs(Sa(t),grid on>> xlabel('omega'),ylabel('H(jw)')>> title('Sa(t)的频谱')由图可知,Sa(t)的频谱大部分集中在0,6之间,设其截止频率为wm=6,因而奈奎斯特间隔Ts=12fm=

27、6,采用截止频率wc=1.2×wm的低通滤波器对抽样信号滤波后重建信号f(t),并计算重建信号与原Sa(t)信号的绝对误差:>> wm=6;>> wc=1.2*wm;>> Ts=0.4;>> n=-100:100;>> nTs=n*Ts;>> fs=sinc(nTs/pi);>> t=-6:0.1:6;>> ft=Ts*wc/pi*fs*sinc(wc/pi)*(ones(length(nTs),1)*t-nTs'*ones(1,length(t);>> t1=-6:0

28、.1:6;>> f1=sinc(t1/pi);>> subplot(311)>> plot(t1,f1,':'),hold on>> stem(nTs,fs),grid on>> axis(-6 6 -0.5 1)>> xlabel('nTs'),ylabel('f(nTs)');>> title('抽样间隔Ts=0.4时的抽样信号f(nTs)')>> hold off>> subplot(312)>> plot

29、(t,ft),grid on>> axis(-6 6 -0.5 1)>> xlabel('t'),ylabel('f(t)');>> title('由f(nTs)信号重建得到Sa(t)信号')>> error=abs(ft-f1);>> subplot(313)>> plot(t,error),grid on>> xlabel('t'),ylabel('error(t)');>> title('重建信号与原信号的

30、绝对误差')第10章 拉普拉斯变换10.1试用MATLAB命令求下列函数的拉普拉斯变换。(1)te-3t(2)(1+3t+5t2)e-2t解:(1)>> f=sym('t*exp(-3*t)');>> L=laplace(f) L = 1/(s + 3)2(2)>> f=sym('(1+3*t+5*t2)*exp(-2*t)');>> L=laplace(f) L = 1/(s + 2) + 3/(s + 2)2 + 10/(s + 2)310.2试用MATLAB命令求下列函数的拉普拉斯反变换。(1)12s

31、+3(2)3(s+5)(s+2)(3)3s(s+5)(s+2)(4)1s2(s2+2s+2)解:(1)>> F=sym('1/(2*s+3)');>> f=ilaplace(F) f = exp(-(3*t)/2)/2(2)>> F=sym('3/(s+5)*(s+2)');>> f=ilaplace(F) f = exp(-2*t) - exp(-5*t)(3)>> F=sym('3*s/(s+5)*(s+2)');>> f=ilaplace(F) f = 5*exp(-5

32、*t) - 2*exp(-2*t)(4)>> F=sym('1/(s2*(s2+2*s+2)');>> f=ilaplace(F) f = t/2 + (exp(-t)*cos(t)/2 - 1/210.3已知某线性时不变系统的系统函数为Hs=4s2+4s+4s3+3s2+2s利用MATLAB的拉普拉斯变换法求系统的单位阶跃响应。解:输入信号xt=u(t)的拉普拉斯变换为Xs=1s,故Ys=Hs*Xs=4s2+4s+4s4+3s3+2s2>> F=sym('(4*s2+4*s+4)/(s4+3*s3+2*s2)');>&

33、gt; f=ilaplace(F) f = 2*t + 4*exp(-t) - 3*exp(-2*t) - 1所以单位阶跃响应为yt=(2t+4e-t-3e-2t-1)u(t).第11章 连续时间LTI系统的零极点分析11.1试用MATLAB命令画出下列系统函数的零极点分布图,并判断其稳定性。(1)Hs=s(s+2)s2+8(2)Hs=s(s-2)s2+8(3)Hs=s2s2+4s+8(4)Hs=s2s2-4s+8(5)Hs=ss3-4s2+8s解:(1)>> b=1 2 0;>> a=1 0 8;>> sys=tf(b,a)>> pzmap(s

34、ys)因为极点在虚轴上,所以系统临界稳定。(2)>> b=1 -2 0;>> a=1 0 8;>> sys=tf(b,a);>> pzmap(sys)系统临界稳定。(3)>> b=1 0 0;>> a=1 4 8;>> sys=tf(b,a);>> pzmap(sys)系统稳定。(4)>> b=1 0 0;>> a=1 -4 8;>> sys=tf(b,a);>> pzmap(sys)系统不稳定。(5)>> b=1 0;>> a

35、=1 -4 8 0;>> sys=tf(b,a);>> pzmap(sys)系统不稳定。11.2试用MATLAB命令实现下列含有二阶极点的系统函数所对应的时域冲击响应的波形,并分析系统函数对时域波形的影响。(1)H1(s)=1s2(2)H2s=1(s+1)2(3)H3(s)=14s(s2+49)2解:(1)>> b1=1;>> a1=1 0 0;>> sys1=tf(b1,a1);>> subplot(121)>> pzmap(sys1)>> subplot(122)>> impulse

36、(b1,a1)系统在虚轴上有二阶极点,系统不稳定。(2)>> b2=1;>> a2=1 2 1;>> sys2=tf(b2,a2);>> subplot(121)>> pzmap(sys2)ROC为Res-1,系统稳定。(3)>> b3=14 0;>> a3=1 0 98 0 2401;>> sys3=tf(b3,a3);>> subplot(121)>> pzmap(sys3)>> subplot(122)>> impulse(b3,a3)>&

37、gt; axis(0 10 -20 20)s右半平面有极点,系统不稳定。11.3已知系统函数为Hs=1s2+2as+1,试用MATLAB画出a=0、14、1、2时系统的零极点分布图。如果系统是稳定的,画出系统的幅频特性曲线,并分析系统极点位置对系统的幅频特性有何影响?(提示:利用freqs函数。)解:(1)a=0时:>> b1=1;>> a1=1 0 1;>> sys1=tf(b1,a1);>> pzmap(sys1)系统是不稳定的。(2)a=14时:>> b2=1;>> a2=1 0.5 1;>> sys2=

38、tf(b2,a2);>> subplot(121)>> pzmap(sys2)>> w=-8*pi:0.01:8*pi;>> H=freqs(b2,a2,w)>> subplot(122)>> plot(w,abs(H),grid on>> plot(w,abs(H),grid on>> xlabel('omega(rad/s)'),ylabel('|H(omega)|')>> axis(-10 10 0 2.5)>> title('H

39、(s)=1/(s2+0.5s+1)的幅频特性')(3)a=1时:>> b3=1;>> a3=1 2 1;>> sys3=tf(b3,a3);>> subplot(121)>> pzmap(sys3)>> w=-8*pi:0.01:8*pi;>> H=freqs(b3,a3,w);>> subplot(122)>> plot(w,abs(H),grid on>> xlabel('omega(rad/s)'),ylabel('|H(omega)|&

40、#39;)>> title('H(s)=1/(s2+2s+1)的幅频特性')(4)a=2时:>> b4=1;>> a4=1 4 1;>> sys4=tf(b4,a4);>> subplot(121)>> pzmap(sys4)>> w=-8*pi:0.01:8*pi;>> H=freqs(b4,a4,w);>> subplot(122)>> plot(w,abs(H),grid on>> xlabel('omega(rad/s)')

41、,ylabel('|H(omega)|')>> title('H(s)=1/(s2+4s+1)的幅频特性')综上可知,极点离虚轴距离越远,冲激响应波形变化越快,但越快稳定。第12章 离散时间信号的表示及运算12.1 试用MATLAB命令分别绘出下列各序列的波形图。(1)xn=12nu(n)(2)xn=2nu(n)(3)xn=-12nu(n)(4)xn=-2nu(n)(5)xn=2n-1u(n-1)(6)xn=12n-1u(n)解:>> n=-10:10;>> x1=(0.5).n.*uDT(n);>> x2=2.n

42、.*uDT(n);>> x3=(-0.5).n.*uDT(n);>> x4=(-2).n.*uDT(n);>> x5=2.(n-1).*uDT(n-1);>> x6=(0.5).(n-1).*uDT(n);>> subplot(321);>> stem(n,x1,'fill'),grid on>> title('x(n)=(1/2)nu(n)'),xlabel('n')>> subplot(322);>> stem(n,x2,'fi

43、ll'),grid on>> title('x(n)=(2)nu(n)'),xlabel('n')>> subplot(323);>> stem(n,x3,'fill'),grid on>> title('x(n)=(-1/2)nu(n)'),xlabel('n')>> subplot(324);>> stem(n,x4,'fill'),grid on>> title('x(n)=(-2)nu(n)&

44、#39;),xlabel('n')>> subplot(325);>> stem(n,x5,'fill'),grid on>> title('x(n)=2(n-1)u(n)'),xlabel('n')>> subplot(326);>> stem(n,x6,'fill'),grid on>> title('x(n)=(1/2)(n-1)u(n)'),xlabel('n')12.2试用MATLAB分别绘出下列各序列

45、的波形图(1)xn=sinn5(2)xn=cosn10-5(3)xn=(56)nsin(n5)(4)xn=(32)nsin(n5)解:>> n=-10:10;>> x1=sin(n*pi/5);>> x2=cos(n*pi)/10-pi/5);>> x3=(5/6).n.*sin(n.*pi)/5);>> x4=(3/2).n.*sin(n.*pi)/5);>> subplot(221)>> stem(n,x1,'fill'),grid on>> title('x(n)=si

46、n(n*pi/5)'),xlabel('n');>> subplot(222);>> stem(n,x2,'fill'),grid on;>> title('x(n)=cos(n*pi/10-pi/5)'),xlabel('n');>> subplot(223);>> stem(n,x3,'fill'),grid on;>> title('x(n)=(5/6)nsin(n*pi/5)'),xlabel('n

47、9;);>> subplot(224);>> stem(n,x4,'fill'),grid on;>> title('x(n)=(3/2)nsin(n*pi/5)'),xlabel('n');12 离散时间LTI系统的时域分析13.1试用MATLAB命令求解以下离散时间系统的单位取样响应。(1)3yn+4yn-1+yn-2=xn+x(n-1)(2)52yn+6yn-1+10yn-2=x(n)解:(1)>> a=3 4 1;>> b=1 1;>> n=-5:15;>>

48、; x=impDT(n);>> y=filter(b,a,x);>> stem(n,y,'fill'),grid on>> xlabel('n'),title('3y(n)+4y(n-1)+y(n-2)=x(n)+x(n-1)的单位取样响应')(2)>> a=5/2 6 10;>> b=1;>> n=0:30;>> impz(b,a,30),grid on>> xlabel('n'),title('5/2y(n)+6y(n-1)

49、+10y(n-2)=x(n)的单位取样响应')13.2已知某系统的单位取样响应为hn=(78)nun-un-10,试用MATLAB求当激励信号为xn=un-u(n-5)时,系统的零状态响应。解:>> nx=-2:7;>> nh=-4:14;>> x=uDT(nx)-uDT(nx-5);>> h=(7/8).nh.*(uDT(nh)-uDT(nh-10);>> y=conv(x,h);>> ny1=nx(1)+nh(1);>> ny=ny1+(0:(length(nx)+length(nh)-2);>> subplot(311)>> stem(nx,x,'fill

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论