云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 信号与系统实验教程MATLAB

信号与系统实验教程MATLAB

  • 62 次阅读
  • 3 次下载
  • 2025/5/30 16:22:39

% Program1_1

% This program is used to generate a sinusoidal signal and draw its plot clear, % Clear all variables

close all, % Close all figure windows

dt = 0.01; % Specify the step of time variable t = -2:dt:0.2; % Specify the interval of time x = sin(2*pi*t); % Generate the signal

plot(t,x) % Open a figure window and draw the plot of x(t) title('Sinusoidal signal x(t)') xlabel('Time t (sec)')

常用的图形控制函数

axis([xmin,xmax,ymin,ymax]):图型显示区域控制函数,其中xmin为横轴的显示起点,xmax为横轴的显示终点,ymin为纵轴的显示起点,ymax为纵轴的显示终点。

有时,为了使图形具有可读性,需要在所绘制的图形中,加上一些网格线来反映信号的幅度大小。MATLAB中的grid on/grid off可以实现在你的图形中加网格线。

grid on:在图形中加网格线。 grid off:取消图形中的网格线。

x = input(‘Type in signal x(t) in closed form:’) 在《信号与系统》课程中,单位阶跃信号u(t) 和单位冲激信号δ(t) 是二个非常有用的信号。它们的定义如下

?t?????(t)dt?1t?0 1.1(a)

?(t)?0,?1,u(t)???0,t?0t?0 1.1(b)

这里分别给出相应的简单的产生单位冲激信号和单位阶跃信号的扩展函数。产生单位冲激信号的扩展函数为:

function y = delta(t) dt = 0.01;

y = (u(t)-u(t-dt))/dt;

产生单位阶跃信号的扩展函数为: % Unit step function function y = u(t)

y = (t>=0); % y = 1 for t > 0, else y = 0

请将这二个MATLAB函数分别以delta 和u为文件名保存在work文件夹中,以后,就可以像教材中的方法使用单位冲激信号δ(t) 和单位阶跃信号u(t)。

2.2离散时间信号的仿真

程序Program1_2用来产生离散时间信号x[n]=sin(0.2πn)。

% Program1_2

% This program is used to generate a discrete-time sinusoidal signal and draw its plot clear, % Clear all variables

close all, % Close all figure windows n = -10:10; % Specify the interval of time x = sin(0.2*pi*n); % Generate the signal

stem (n,x) % Open a figure window and draw the plot of x[n] title ('Sinusoidal signal x[n]') xlabel ('Time index n')

请仔细阅读该程序,比较程序Program1_1和Program1_2中的不同之处,以便自己编程时能够正确使用这种方法方针连续时间信号和离散时间信号。 程序Program1_3用来仿真下面形式的离散时间信号: x[n]={...., 0.1, 1.1, -1.2, 0, 1.3, ….} ↑n=0

% Program1_3

% This program is used to generate a discrete-time sequence % and draw its plot

clear, % Clear all variables

close all, % Close all figure windows

n = -5:5; % Specify the interval of time, the number of points of n is 11. x = [0, 0, 0, 0, 0.1, 1.1, -1.2, 0, 1.3, 0, 0]; % Generate the signal

stem(n,x,'.') % Open a figure window and draw the plot of x[n] grid on,

title ('A discrete-time sequence x[n]') xlabel ('Time index n')

由于在程序的stem(n,x,'.') 语句中加有'.'选项,因此绘制的图形中每根棒条线的顶端是一个实心点。

如果需要在序列的前后补较多的零的话,可以利用函数zeros(),其语法为:

zeros(1, N):圆括号中的1和N表示该函数将产生一个一行N列的矩阵,矩阵中的所有元素均为零。利用这个矩阵与序列x[n]进行组合,从而得到一个长度与n相等的向量。

例如,当 x[n]={ 0.1, 1.1, -1.2, 0, 1.3} 时,为了得到程序Program1_3中的序列, ↑n=0

可以用这个MATLAB语句x = [zeros(1,4) x zeros(1, 2)] 来实现。用这种方法编写的程序如下:

% Program1_4

% This program is used to generate a discrete-time sinusoidal signal % and draw its plot

clear, % Clear all variables

close all, % Close all figure windows n = -5:5; % Specify the interval of time

x = [zeros(1,4), 0.1, 1.1, -1.2, 0, 1.3, zeros(1,2)]; % Generate the sequence stem (n,x,'.') % Open a figure window and draw the plot of x[n] grid on,

title ('A discrete-time sequence x[n]') xlabel ('Time index n')

离散时间单位阶跃信号u[n]定义为 u[n]???1,?0,n?0n?0 1.2

离散时间单位阶跃信号u[n]除了也可以直接用前面给出的扩展函数来产生,还可以利用MATLAB内部函数ones(1,N) 来实现。这个函数类似于zeros(1,N),所不同的是它产生的矩阵的所有元素都为1。

值得注意的是,利用ones(1,N) 来实现的单位阶跃序列并不是真正的单位阶跃序列,而是一个长度为N单位门(Gate)序列,也就是u[n]-u[n-N]。但是在一个有限的图形窗口中,我们看到的还是一个单位阶跃序列。

在绘制信号的波形图时,有时我们需要将若干个图形绘制在图一个图形窗口中,这就需要使用MATLAB的图形分割函数subplot(),其用法是在绘图函数stem或plot之前,使用图形分割函数subplot(n1,n2,n3),其中的参数n1,n2和n3的含义是,该函数将把一个图形窗口分割成n1xn2个子图,即将绘制的图形将绘制在第n3个子图中。

2.3信号的时域变换 2.3.1 信号的时移

信号的时移可用下面的数学表达式来描述:

设一个连续时间信号为x(t),它的时移y(t) 表示为:

y(t) = x(t - t0) 1.3

其中,t0为位移量。若t0为正数,则y(t)等于将x(t)右移t0秒之后的结果。反之,若t0为负数,则y(t)等于将x(t)左移t0秒之后的结果。

在MATLAB中,时移运算与数学上习惯表达方法完全相同。 程序Program1_5对给定一个连续时间信号x(t) = e-0.5tu(t),对它分别左移2秒钟和右移2秒钟得到信号x1(t) = e-0.5(t+2)u(t+2)和x2(t) = e-0.5(t-2)u(t-2)。

% Program1_5

% This program is used to implement the time-shift operation

% on a continuous-time signal and to obtain its time-shifted versions % and to draw their plots. clear,close all, t = -5:0.01:5;

x = exp(-0.5*t).*u(t); % Generate the original signal x(t)

x1 = exp(-0.5*(t+2)).*u(t+2); % Shift x(t) to the left by 2 second to get x1(t) x2 = exp(-0.5*(t-2)).*u(t-2); % Shift x(t) to the right by 2 second to get x2(t) subplot(311)

plot(t,x) % Plot x(t) grid on,

title ('Original signal x(t)') subplot (312)

plot (t,x1) % Plot x1(t) grid on,

title ('Left shifted version of x(t)') subplot (313)

plot (t,x2) % Plot x2(t) grid on,

title ('Right shifted version of x(t)') xlabel ('Time t (sec)')

2.3.2 信号的时域反褶

对一个信号x[n]的反褶运算在数学上表示为

y[n] = x[-n] 1.4

这种反褶运算,用MATLAB实现起来也是非常简单的。有多种方法可以实现信号的反褶运算。

方法一,修改绘图函数plot(t,x)和stem(n,x)中的时间变量t和n,即用-t和-n替代原来的t和n,这样绘制出来的图形,看起来就是原信号经时域反褶后的版本。

方法二,直接利用原信号与其反褶信号的数学关系式来实现。这种方法最符合信号反褶运算的实际意义。

方法三,使用MATLAB内部函数fliplr()来实现信号的反褶运算。其用法如下: y = fliplr(x):其中x为原信号x(t)或x[n],而y则为x的时域反褶。需要说明的是,函数fliplr()对信号作时域反褶,仅仅将信号中各个元素的次序作了一个反转,这种反转处理是独立于时间变量t和n的。因此,如果信号与其时间变量能够用一个数学函数来表达的话,那么建议将时间变量t和n的范围指定在一个正负对称的时间区间即可。

2.3.3 信号的时域尺度变换

信号x(t)的时域尺度变换在数学描述为

y(t) = x(at), 1.5

其中a为任意常数。根据a的不同取值,这种时域尺度变换对信号x(t)具有非常不同的影响。 当a = 1时,y(t) = x(t);

当a = -1时,y(t) = x(-t),即y(t)可以通过将x(t)反褶运算而得到; 当a > 1时,y(t) = x(at),y(t)是将x(t)在时间轴上的压缩而得到; 当0 < a < 1时,y(t) = x(at),y(t)是将x(t)在时间轴上的扩展而得到;

当 -1 < a < 0时,y(t) = x(at),y(t)是将x(t)在时间轴上的扩展同时翻转而得到; 当 a < -1时,y(t) = x(at),y(t)是将x(t)在时间轴上的压缩同时翻转而得到;

由此可见,信号的时域尺度变换,除了对信号进行时域压缩或扩展外,还可能包括对信号的时域反褶运算。实际上,MATLAB完成式1.5的运算,并不需要特殊的处理,按照数学上的常规方法即能完成。

2.3.4周期信号

在《信号与系统》课程中,周期信号是一类非常重要的信号。给定一个信号x(t)或x[n],如果满足

x(t) = x(t+kT) 1.6

搜索更多关于: 信号与系统实验教程MATLAB 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

% Program1_1 % This program is used to generate a sinusoidal signal and draw its plot clear, % Clear all variables close all, % Close all figure windows dt = 0.01; % Specify the step of time variable t = -2:dt:0.2; % Specify the interval of time x = sin(2*pi*t); % Generate the signal plot(t,x)

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com