文档介绍:实验一信号的时域表示方法
一、实验目的
1、熟悉和掌握常用的用于信号与系统时域仿真分析的MATLAB函数;
2、掌握连续时间和离散时间信号的MATLAB产生及编程;
基本要求:掌握用MATLAB描述连续时间信号和离散时间信号的方法,能够编写MATLAB程序,并且以图形的方式表示各种信号的波形。
连续时间信号的仿真
编写Program1_1:用MATLAB对一个正弦信号进行仿真的程序.
% 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 = ; % Specify the step of time variable
t = -2:dt: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为纵轴的显示终点。
说明:
(1)MATLAB中的grid on/grid off可以实现在你的图形中加网格线。
grid on:在图形中加网格线。
grid off:取消图形中的网格线。
x = input(‘Type in signal x(t) in closed form:’)
(2)产生单位冲激信号的扩展函数为:
function y = delta(t)
dt = ;
y = (u(t)-u(t-dt))/dt;
(3)产生单位阶跃信号的扩展函数为:
% Unit step function
function y = u(t)
y = (t>=0); % y = 1 for t > 0, else y = 0
离散时间信号的仿真
(1)程序Program1_2用来产生离散时间信号x[n]=sin()。
% 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(*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')
(2) 程序Program1_3用来仿真下面形式的离散时间信号:
x[n]={...., , , -, 0, , ….}
↑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, , 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,'.') 语句中加有'.'选项,因此绘制的图形