您好,欢迎来到微智科技网。
搜索
您的当前位置:首页基于MATLAB的信号与系统实验指导编程练习

基于MATLAB的信号与系统实验指导编程练习

来源:微智科技网
基于MATLAB的信号与系统实验指导编程练习

2连续时间信号在M A T L A B中的表⽰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)')

(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('t[u(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+cos(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;>> 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 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);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;>> ft=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 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))-uC T(t-2);>> plot(t,f)>> axis([-4 4 -1 2])>> title('图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);grid 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]);

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('fo')

4连续时间信号的卷积计算

4-1⽤MATLAB命令绘出下列信号的卷积积分的时域波形图>> 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编程实现其各次谐波的叠加,并验证其收敛性。

6-2 试⽤MATLAB分析图6-5中周期三⾓信号的频谱。当周期三⾓信号的周期和三⾓信号的宽度变化时,试观察分析其频谱的变化。

7 傅⾥叶变换及其性质

7-1试⽤MATLAB命令求下列信号的傅⾥叶变换,并绘出其幅度谱和相位谱。(1)(2)

解:(1)ft1=sym('sin(2*pi*(t-1))/(pi*(t-1))');>> Fw1=simplify(fourier(ft1));

>> subplot(211)

>> ezplot(abs(Fw1)),grid on>> title('幅度谱')

>> phase=atan(imag(Fw1)/real(Fw1));>> subplot(212)>> ezplot(phase);grid on>> title('相位谱')

(2)

7-2.试⽤MATLAB命令求下列信号的傅⾥叶反变换,并绘出其时域信号图。(1)(2)解:(1)>> syms t

>> Fw=sym('10/(3+w*i)-4/(5+w*i)');>> ft=ifourier(Fw,t);>> ezplot(ft),grid on

(2)>> syms t

>> Fw2=sym('exp(-4*w^2)');>> ft2=ifourier(Fw2,t)ft2 =

exp(-t^2/16)/(4*pi^(1/2))

3.试⽤MATLAB数值计算⽅法求图7-8所⽰信号的傅⾥叶变换,并画出其频谱图。解:

4.已知两个门信号的卷积为三⾓波信号,试⽤MATLAB命令验证傅⾥叶变换的时域卷积定理。

解:将门函数先进⾏时域卷积运算,再将卷积后的结果做傅⾥叶变换,程序和结果如下:dt = 0.01; t = -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 = uCT(t+0.5)- uCT(t-0.5);ft=sym('f1');Fw = fourier(ft);Fw=Fw*Fw

Fw =-4*pi^2*dirac(1,w)^2

由此来验证傅⾥叶变换的时域卷积定理第8章连续时间LTI系统的频率特性及频域分析

8.1试⽤MATLAB命令求图8-8所⽰电路系统的幅频特性和相频特性。已知R=10Ω,L=2H,C=0.1F解:由电路知识可得,该电路系统的频率响应为MATLAB源程序:>> w=-6*pi: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('\\omega(rad/s)'),ylabel('\\phi(\\omega)')>> title('电路系统的相频特性')

8.2已知系统微分⽅程和激励信号如下,试⽤MATLAB命令求系统的稳态响应。(1),;(2),。

解:(1)频率响应为>> t=0:0.01:20;>> H=(w*i)/(w*i+3/2);>> f=cos(2*t);

>> 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('稳态响应的波形')

(2)频率响应为MATLAB源程序:>> 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);grid 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。现在⽤抽样频率f s=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)') >> 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,':'),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.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(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]之间,设其截⽌频率为,因⽽奈奎斯特

间隔,采⽤截⽌频率的低通滤波器对抽样信号滤波后重建信号,并计算重建信号与原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.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(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('重建信号与原信号的绝对误差')

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务