资源描述
信 号 与 系 统
实 验 教 程(只有答案)
(实验报告)
这么玩!
目录
实验一 信号与系统的时域分析 2
三、实验内容及步骤 2
实验二 连续时间信号的频域分析 14
三、实验内容及步骤 14
实验三 连续时间LTI系统的频域分析 35
三、实验内容及步骤 35
实验四 通信系统仿真 41
三、实验内容及步骤 41
实验五 连续时间LTI系统的复频域分析 51
三、实验内容及步骤 51
实验一 信号与系统的时域分析
三、实验内容及步骤
实验前,必须首先阅读本实验原理,读懂所给出的全部范例程序。实验开始时,先在计算机上运行这些范例程序,观察所得到的信号的波形图。并结合范例程序应该完成的工作,进一步分析程序中各个语句的作用,从而真正理解这些程序。
实验前,一定要针对下面的实验项目做好相应的实验准备工作,包括事先编写好相应的实验程序等事项。
Q1-1:修改程序Program1_1,将dt改为0.2,再执行该程序,保存图形,看看所得图形的效果如何?
dt = 0.01时的信号波形 dt = 0.2时的信号波形
这两幅图形有什么区别,哪一幅图形看起来与实际信号波形更像?
答:
Q1-2:修改程序Program1_1,并以Q1_2为文件名存盘,产生实指数信号x(t)=e-0.5t。 要求在图形中加上网格线,并使用函数axis()控制图形的时间范围在0~2秒之间。然后执行该程序,保存所的图形。
修改Program1_1后得到的程序Q1_2如下: 信号x(t)=e-0.5t的波形图
clear, % Clear all variables
close all, % Close all figure windows
dt = 0.2; % Specify the step of time variable
t = -2:dt:2; % Specify the interval of time
x = exp(-0.5*t); % Generate the signal
plot(t,x)
grid on;
axis ([0 2 0 1 ])
title('Sinusoidal signal x(t)')
xlabel('Time t (sec)')
Q1-3:修改程序Program1_1,并以Q1_3为文件名存盘,使之能够仿真从键盘上任意输入的一个连续时间信号,并利用该程序仿真信号x(t)=e-2t。
修改Program1_1后得到的程序Q1_3如下: 信号x(t)=e-2t的波形图
clear,
close all,
dt = 0.2;
t = -2:dt:2;
x=input('Input x(t):');
plot(t,x)
grid on;
axis ([0 2 -1 1 ])
title('Sinusoidal signal x(t)')
xlabel('Time t (sec)')
Q1-4:将实验原理中所给的单位冲激信号和单位阶跃信号的函数文件在MATLAB文件编辑器中编写好,并分别以文件名delta和u存入work文件夹中以便于使用。
抄写函数文件delta如下: 抄写函数文件u如下:
function y = delta(t) % Unit step function
dt = 0.01; function y = u(t)
y = (u(t)-u(t-dt))/dt; y = (t>=0); % y = 1 for t > 0, else y = 0
Q1-5:修改程序Program1_4,并以Q1_5为文件名存盘,利用axis()函数,将图形窗口的横坐标范围改为-2≤n≤5,纵坐标范围改为-1.5≤ x ≤1.5。
修改Program1_4后得到的程序Q1_5如下: 信号的波形图
clear,
close all,
n = -5:5;
x = [zeros(1,4), 0.1, 1.1, -1.2, 0, 1.3, zeros(1,2)];
stem (n,x,'.')
grid on,
axis([-2 5 -1.5 1.5]);
title ('A discrete-time sequence x[n]')
xlabel ('Time index n')
Q1-6:仿照前面的示例程序的编写方法,编写一个MATLAB程序,以Q1_6为文件名存盘,使之能够在同一个图形窗口中的两个子图中分别绘制信号x[n]=0.5|n| 和x(t)=cos(2πt)[u(t)-u(t-3)]。要求选择的时间窗能够表现出信号的主要部分(或特征)。
编写的程序Q1_6如下: 信号x[n]=0.5|n| 的波形图和信号x(t)=cos(2πt)[u(t)-u(t-3)]的波形图
clear,close all,
t = -1:0.01:4;
xt = cos(2*pi*t).*(u(t)-u(t-3));
n=-5:5;
xn=(0.5).^abs(n);
subplot(211)
plot(t,xt)
grid on,
title ('Original signal x(t)')
subplot(212)
stem(n,xn,'.')
grid on,
title ('Original signal x(n)')
xlabel ('Time t (sec)')
Q1-7:根据示例程序的编程方法,编写一个MATLAB程序,以Q1_7为文件名存盘,由给定信号x(t) = e-0.5tu(t) 求信号y(t) = x(1.5t+3),并绘制出x(t) 和y(t)的图形。
编写的程序Q1_7如下:
编写产生x(t)的函数文件x.m
function y=x(t)
y=exp(-0.5*t).*u(t);
clear,close all,
t = -3:0.01:4;
xt = x(t); % Generate the original signal x(t)
yt=x(1.5*t+3);
subplot(211)
plot(t,xt) % Plot x(t)
grid on,
title ('Original signal x(t)')
subplot(212)
plot(t,yt) % Plot x(t)
grid on,
title ('Original signal y(t)')
xlabel ('Time t (sec)')
信号x(t)的波形图 信号y(t) = x(1.5t+3) 的波形图
Q1-8:给定一个离散时间信号x[n] = u[n] – u[n-8],仿照示例程序Program1_5,编写程序Q1_8,产生x[n]的左移序列x1[n] = x[n+6]和右移序列x2[n] = x[n-6],并在同一个图形窗口的三个子图中分别绘制这三个序列的图形。
编写的程序Q1_8如下:
编写产生x(t)的函数文件xx.m
function y=xx(n)
y=u(n)-u(n-8);
clear,close all,
n = -10:15;
x =xx(n); % Generate the original signal x(n)
x1 = xx(n+6); % Shift x(t) to the left by 2 second to get x1(n+6)
x2 =xx(n-6); % Shift x(t) to the right by 2 second to get x2(n-6)
subplot(311)
stem(n,x,'.') % Plot x(t)
grid on,
title ('Original signal x(n)')
subplot (312)
stem (n,x1,'.') % Plot x1(t)
grid on,
title ('Left shifted version of x(n)')
subplot (313)
stem (n,x2,'.') % Plot x2(t)
grid on,
title ('Right shifted version of x(n)')
xlabel ('Time t (sec)')
信号波形图
Q1-9:编写程序Q1_9,使之能够接受以键盘方式输入的定义在不同时间段的两个不同连续时间信号并完成卷积运算,分别绘制这两个信号及其卷积的结果的图形,图形按照2´2分割成四个子图。
编写的程序Q1_9如下:
clear;close all;
dt = 0.01;
t0=input('Input first signal t0:');t1=input('Input first first signal t1:');
tx = t0:dt:t1;
x = input('Input first signal variable(tx) :');
t2=input('Input second signal t0:');t3=input('Input second signal t1:');
th=t2:dt:t3;
h = input('Input second signal variable(th) :')
y = dt*conv(x,h); % Compute the convolution of x(t) and h(t)
subplot(221)
plot(tx,x), grid on, title('Signal x(t)')
xlabel('Time t sec')
subplot(222)
plot(th,h), grid on, title('Signal h(t)')
xlabel('Time t sec')
subplot(313)
plot(y), grid on, title('The convolution of x(t) and h(t)')
xlabel('Time t sec')信号x (t)、h(t)和x (t)*h(t)的波形图
Q1-10:给定两个离散时间序列
x[n] = 0.5n{u[n]-u[n-8]}
h[n] = u[n]-u[n-8]
编写程序Q1_10,计算它们的卷积,并分别绘制x[n]、h[n]和它们的卷积y[n]的图形。
编写的程序Q1_10如下:
n=0:10;
x = (0.5).^n.*(u(n)-u(n-8));
h = u(n)-u(n-8);
y =conv(x,h); % Compute the convolution of x(t) and h(t)
subplot(221)
stem(n,x,'.'), grid on, title('Signal x(n)')
subplot(222)
stem(n,h,'.'), grid on, title('Signal h(n)')
subplot(212)
stem(y), grid on, title('The convolution of x(n) and h(n)'),
xlabel('Time t sec');
信号x[n]、h[n]和y[n]的波形图
Q1-11已知一个序列为
编写MATLAB程序Q1_11,能够将x[n]以N = 8为周期进行周期延拓得到一个周期为N =8的周期序列y[n],并分别绘制x[n]和y[n]图形。
编写的程序Q1_11如下:
U4.m
function y=u4(n)
y=n.*(u(n)-u(n-5));
Q1——11.m
clear, close all;
n =-16:32
x=u4(n);
T = 8; y = 0;
for k = -2:4;
y =y+u4(n-k*T);
end
subplot(211)
stem(n,x,'.');
grid on,
title ('Original signal x(n)')
xlabel('Time t sec')
subplot(212)
stem(n,y);
title ('period signal x(n)')
xlabel('Time t sec')
grid on,信号x[n]的波形图 信号y[n]的波形图
Q1-12 仿照范例程序Program1_7,编写程序Q1_12,计算并绘制由如下微分方程表示的系统在输入信号为x(t) = (e-2t - e-3t)u(t)时的零状态响应和你手工计算得到的系统零状态响应曲线。
手工计算得到的系统零状态响应的数学表达式是:
编写的程序Q1_12如下: 用MATLAB绘制的手工计算的系统响应
clear, close all;
num = input('Type in the right coefficient vector of differential equation:');
den = input('Type in the left coefficient vector of differential equation:');
t = 0:0.01:8;
x = input('Type in the expression of the input signal x(t):');
y=lsim(num,den,x,t);plot(t,y)
执行程序Q1_12得到的系统响应
Q1-13:利用程序Q1_9,验证卷积的相关性质。
(a) 验证性质:
选择信号x(t)的数学表达式为:sin(t)
x(t)、δ(t)和x(t)*δ(t)的波形
验证所得结论是:
(b) 验证性质:
选择信号x(t)的数学表达式为:sin(t) t0=2
x(t)、δ(t-t0) 和的波形
验证所得结论是:
(c) 验证性质:
选择信号x(t)的数学表达式为: sin(t) 选择的t1 = 2 秒,t2 = 3 秒。
执行程序Q1_9,输入信号x(t-t1) 和δ(t-t2) 的数学表达式,得到的信号及其卷积的波形图如下:
执行程序Q1_9,输入信号x(t-t2) 和δ(t-t1) 的数学表达式,得到的信号及其卷积的波形图如下:
验证所得结论是:
(d) 验证性质:
选择信号x(t)(建议选择一个时限信号)的数学表达式为:u(t)-u(t-3)
的数学表达式为:
手工绘制的波形如下:
执行程序Q1_9,输入信号x(t) 和u(t) 的数学表达式,得到的信号及其卷积的波形图如下:
验证所得结论是:
(e) 验证性质:
选择信号x(t)的数学表达式为: sin(t) 选择信号h(t)的数学表达式为:sin(t)
选择的t0=:1
执行程序Q1_9,输入信号x(t) 和h(t-t0) 的数学表达式,得到的信号及其卷积的波形图如下:
执行程序Q1_9,输入信号x(t-t0) 和h(t) 的数学表达式,得到的信号及其卷积的波形图如下:
验证所得结论是:
Q1-14:做如下总结:
1、信号与系统分析,就是基于信号的分解,在时域中,信号主要分解成:
2、写出卷积的运算步骤,并谈谈你对卷积的一些基本性质的理解。利用MATLAB计算卷积的函数是什么?如何使用?
3、在时域中,描述一个连续时间LTI系统的数学模型有:
4、MATLAB是如何表示一个由微分方程描述的连续时间LTI系统的?求解连续时间LTI系统的单位冲激响应、单位阶跃响应以及系统在某一个输入信号作用下的零状态响应的MATLAB函数有哪些?
四、实验报告要求
1、按要求完整书写你所编写的全部MATLAB程序
2、详细记录实验过程中的有关信号波形图(存于自带的U盘中),图形要有明确的标题。全部的MATLAB图形应该用打印机打印,然后贴在本实验报告中的相应位置,禁止复印件。
3、实事求是地回答相关问题,严禁抄袭。
本实验完成时间: 年 月 日
实验二 连续时间信号的频域分析
三、实验内容及步骤
实验前,必须首先阅读本实验原理,读懂所给出的全部范例程序。实验开始时,先在计算机上运行这些范例程序,观察所得到的信号的波形图。并结合范例程序应该完成的工作,进一步分析程序中各个语句的作用,从而真正理解这些程序。
实验前,一定要针对下面的实验项目做好相应的实验准备工作,包括事先编写好相应的实验程序等事项。
Q2-1 编写程序Q2_1,绘制下面的信号的波形图:
其中,w0 = 0.5π,要求将一个图形窗口分割成四个子图,分别绘制cos(w0t)、cos(3w0t)、cos(5w0t) 和x(t) 的波形图,给图形加title,网格线和x坐标标签,并且程序能够接受从键盘输入的和式中的项数。
抄写程序Q2_1如下:
clear,close all
T = 2; dt = 0.00001; t = -2*pi:dt:2*pi; w0=0.5*pi;
x1 = cos(w0*t);
x3=(-1/3)*cos(3*w0*t);
x5=(1/5)*cos(5*w0*t);
N = input('Type in the number of the harmonic components N = :');
y=0;
for q = 1:N; % Synthesiz the periodic signal y(t) from the finite Fourier series
y = y+(1/q).*sin((q*pi)/2).*cos(q*w0*t);
end;
subplot(221),
plot(t,x1), title('The original signal cos(w0t)');
grid on; axis([-2*pi,2*pi,-1,1]), xlabel('Time t')
subplot(223),
plot(t,x5), title('The original signal (1/5)cos(5w0t)');
grid on; axis([-2*pi,2*pi,-1,1]), xlabel('Time t')
subplot(222)
plot(t,x3), title('The original signal (-1/3)cos(3w0t)');
grid on; axis([-2*pi,2*pi,-1,1]), xlabel('Time t')
subplot(224)
plot(t,y), title('The synthesis signal of x(t)');
grid on; axis([-10,10,-1,1]), xlabel('Index N')
执行程序Q2_1所得到的图形如下:N=10
Q2-2 给程序Program2_1增加适当的语句,并以Q2_2存盘,使之能够计算例题2-1中的周期方波信号的傅里叶级数的系数,并绘制出信号的幅度谱和相位谱的谱线图。
通过增加适当的语句修改Program2_1而成的程序Q2_2抄写如下:
clear,close all
T = 2; dt = 0.00001; t = -2:dt:2;
x1 = u(t)-u(t-1-dt); x = 0;
for m = -1:1
x = x + u(t-m*T) - u(t-1-m*T-dt); % Periodically extend x1(t) to form a periodic signal
end
w0 = 2*pi/T;
N = input('Type in the number of the harmonic components N = :');
L = 2*N+1;
for k = -N:1:N;
ak(N+1+k) = (1/T)*x1*exp(-j*k*w0*t')*dt;
end
phi = angle(ak);
y=0;
for q = 1:L; % Synthesiz the periodic signal y(t) from the finite Fourier series
y = y+ak(q)*exp(j*(-(L-1)/2+q-1)*2*pi*t/T);
end;
subplot(221)
plot(t,x), title('The original signal x(t)'), axis([-2,2,-0.2,1.2]),grid on;
subplot(222)
k=-N:N; stem(ak), title('The ak of x(t)'), axis([-1,1,-0.4,0.4]),grid on;
subplot(223)
k=-N:N; stem(k,abs(ak),'k.'), title('The amplitude |ak| of x(t)'), axis([-N,N,-0.1,0.6]),grid on;
subplot(224)
stem(k,phi,'r.'), title('The phase phi(k) of x(t)'), axis([-N,N,-2,2]), xlabel('Index k'),grid on;
执行程序Q2_2得到的图形
Q2-3 反复执行程序Program2_2,每次执行该程序时,输入不同的N值,并观察所合成的周期方波信号。通过观察,你了解的吉伯斯现象的特点是:
N=5 N=10
N=20 N=40
1、周期信号的傅里叶级数与GIBBS现象
给定如下两个周期信号:
Q2-4 分别手工计算x1(t) 和x2(t) 的傅里叶级数的系数。
信号x1(t) 在其主周期内的数学表达式为:
t+1 -1<t<0
1-t 0<t<1
计算x1(t) 的傅里叶级数的系数的计算过程如下:
k = -10:10;ak=0;
ak = 1/2.* (sin((k)*pi/2)./((k)*pi/2))
N=-10:10;
stem(k,ak);
通过计算得到的x1(t)的傅里叶级数的系数的数学表达式是:1/2.* (sin((k)*pi/2)./((k)*pi/2))
信号x2(t) 在其主周期内的数学表达式为:
1 |t|<0.2
0 0.2<|t|<1
计算x2(t) 的傅里叶级数的系数的计算过程如下:
k = -10:10;ak=0;
ak =sin(k*pi*0.2)./(k*pi)
N=-10:10;
stem(k,ak);
通过计算得到的x1(t)的傅里叶级数的系数的数学表达式是:sin(k*pi*0.2)./(k*pi)
用MATLAB帮助你计算出你手工计算的傅里叶级数的系数ak从-10到10共21个系数。
从命令窗口上抄写x1(t)的21个系数如下:
ak =
Columns 1 through 8
0.0000 0.0354 -0.0000 -0.0455 0.0000 0.0637 -0.0000 -0.1061
Columns 9 through 16
0.0000 0.3183 NaN 0.3183 0.0000 -0.1061 -0.0000 0.0637
Columns 17 through 21
0.0000 -0.0455 -0.0000 0.0354 0.0000
从命令窗口上抄写x2(t)的21个系数如下:
Columns 1 through 8
-0.0000 -0.0208 -0.0378 -0.0432 -0.0312 0.0000 0.0468 0.1009
Columns 9 through 16
0.1514 0.1871 NaN 0.1871 0.1514 0.1009 0.0468 0.0000
Columns 17 through 21
-0.0312 -0.0432 -0.0378 -0.0208 -0.0000
Q2-5 仿照程序Program2_1,编写程序Q2_5,以计算x1(t)的傅里叶级数的系数。
程序Q2_5如下:
编写函数x1.m
function y=x1(t)
y1=t+1;y2=1-t;
y=y1.*(-1<t&t<=0)+y2.*(0<t&t<1);
Q2_5.m
clear,close all
T = 2; dt = 0.00001; t = -8:dt:8;
x11 = x1(t); x = 0;
for m = -8:8
x = x + x1(t-m*T); % Periodically extend x1(t) to form a periodic signal
end
w0 = 2*pi/T;
N = 10;
L = 2*N+1;
for k = -N:1:N;
ak(N+1+k) = (1/T)*x11*exp(-j*k*w0*t')*dt;
end
phi = angle(ak);
y=0;
for q = 1:L; % Synthesiz the periodic signal y(t) from the finite Fourier series
y = y+ak(q)*exp(j*(-(L-1)/2+q-1)*2*pi*t/T);
end;
subplot(211),
plot(t,x), title('The original signal x(t)'), axis([-8,8,-0.2,1.2]),grid on,
subplot(212)
k=-N:N; stem(k,ak,'k.'), title('The factor ak of x(t)'), axis([-N,N,-0.1,0.6]),grid on,
执行程序Q2_5所得到的x1(t)的傅里叶级数的ak从-10到10共21个系数如下:
Columns 1 through 5
0.0000 + 0.0000i 0.0025 + 0.0000i 0.0000 + 0.0000i 0.0041 - 0.0000i 0.0000 - 0.0000i
Columns 6 through 10
0.0081 + 0.0000i -0.0000 - 0.0000i 0.0225 - 0.0000i -0.0000 - 0.0000i 0.2026 + 0.0000i
Columns 11 through 15
0.5000 0.2026 - 0.0000i -0.0000 + 0.0000i 0.0225 + 0.0000i -0.0000 + 0.0000i
Columns 16 through 20
0.0081 - 0.0000i 0.0000 + 0.0000i 0.0041 + 0.0000i 0.0000 - 0.0000i 0.0025 - 0.0000i
Column 21
0.0000 - 0.0000i
与你手工计算的ak相比较,是否相同,如有不同,是何原因造成的?
答:
Q2-6 仿照程序Program2_1,编写程序Q2_6,以计算x2(t) 的傅里叶级数的系数(不绘图)。
程序Q2_6如下:
编写函数x2.m
function y=x2(t)
y1=1;y2=1;
y=y1.*(-0.2<t&t<=0)+y2.*(0<t&t<=0.2);
Q2_6.m
clear,close all
T = 2; dt = 0.00001; t = -8:dt:8;
x11 = x2(t); x = 0;
for m = -8:8
x = x + x2(t-m*T); % Periodically extend x1(t) to form a periodic signal
end
w0 = 2*pi/T;
N = 10;
L = 2*N+1;
for k = -N:1:N;
ak(N+1+k) = (1/T)*x11*exp(-j*k*w0*t')*dt;
end
phi = angle(ak);
y=0;
for q = 1:L; % Synthesiz the periodic signal y(t) from the finite Fourier series
y = y+ak(q)*exp(j*(-(L-1)/2+q-1)*2*pi*t/T);
end;
subplot(211),
plot(t,x), title('The original signal x(t)'), axis([-8,8,-0.2,1.2]),grid on,
subplot(212)
k=-N:N; stem(k,ak,'k.'), title('The factor ak of x(t)'), axis([-N,N,-0.1,0.6]),grid on,
执行程序Q2_6所得到的x2(t)的傅里叶级数的ak从-10到10共21个系数如下:
Columns 1 through 5
0.0000 - 0.0000i -0.0208 + 0.0000i -0.0378 - 0.0000i -0.0432 + 0.0000i -0.0312 + 0.0000i
Columns 6 through 10
-0.0000 + 0.0000i 0.0468 + 0.0000i 0.1009 + 0.0000i 0.1514 - 0.0000i 0.1871 + 0.0000i
Columns 11 through 15
0.2000 0.1871 - 0.0000i 0.1514 + 0.0000i 0.1009 - 0.0000i 0.0468 - 0.0000i
Columns 16 through 20
-0.0000 - 0.0000i -0.0312 - 0.0000i -0.0432 - 0.0000i -0.0378 + 0.0000i -0.0208 - 0.0000i
Column 21
0.0000 + 0.0000i
与你手工计算的ak相比较,是否相同,如有不同,是何原因造成的?
答:
Q2-7 仿照程序Program2_2,编写程序Q2_7,计算并绘制出原始信号x1(t) 的波形图,用有限项级数合成的y1(t) 的波形图,以及x1(t) 的幅度频谱和相位频
展开阅读全文