99网
您的当前位置:首页信号与系统实验指导书

信号与系统实验指导书

来源:99网


信号与系统(双语)实验指导书

Signals and Systems Experiment Guide

第一版

First Edition

徐艳平 杨惠 姬军鹏 王海燕 编写

曾 光 审

西安理工大学自动化学院电气工程系

二零零七年十一月

Contents

1 Signal Spectrum Analysis…………………………..…….……1 2 Signal Sampling……………………………………………..…4 3 System Characteristics………………………………….…...…8 4 Analysis of Continuous-time System in the s-domain……..…13 5 Analysis of Discrete-time System in the z-domain………...…18

附 录 A 信号与系统实验系统操作步骤…………………… 23 附 录 B MATALB在信号与系统中的应用……………………25 附 录 C 实验报告书写要求………………………………… 38

前 言

本实验指导书旨在配合信号与系统双语教学,训练学生掌握信号与系统的基本理论及其应用,以培养学生具有从事科学研究的能力。书中涵盖了信号与系统中有关信号及系统的时域、频域、复频域及z域分析方法的核心内容:信号的频谱分析,包括连续时间周期信号和非周期信号的频谱;信号的采样以及信号的恢复;一阶和二阶系统时域和频域特性;连续时间系统的s域分析,包括系统函数的零极点分布,单位冲激响应和幅频响应的求解;离散时间系统的z域分析,系统函数零极点分布,单位冲激响应和幅频响应的求解。

实验利用MATLAB仿真软件来进行,实验中主要用到信号与系统教学软件和MATLAB软件中的m文件编程。信号的频谱分析,信号的采样以及系统时域和频域特性三个实验是利用信号与系统教学软件完成,实验系统界面引导,利用了MATLAB软件的特点,操作简便、界面直观。连续时间系统的s域分析和离散时间系统的z域分析实验则利用MATLAB中的m文件编程实现,利用了MATALB中所提供的功能强大的专用函数,实现对连续和离散系统的分析,需要学生进行编程,增强学生分析问题、处理问题、解决问题的能力。

本实验指导书可作为电子信息科学与技术、电气、通信工程等开设信号与系统双语课程的本科生的实验教材。

Signals and Systems Experiment Guide

Experiment 1 Signal Spectrum Analysis

1.1 Aims of Experiment

1. Comprehend the characteristics of signals from viewpoints of frequency domain.

2. Master the Fourier analysis method of periodic and aperiodic signals. 3. Master the spectrum of continuous-time periodic signals and its representation.

4. Master the spectrum of continuous-time aperiodic signals and its

representation.

5. Comprehend the composition of square wave.

1.2 Contents of Experiment

1. Spectrum of continuous-time periodic signals.

Run the “Signals and Systems Experiment Systems” and then “Spectrum Analysis”. Sketch the following signals. a.

Plot continuous-time sinusoidal signal and sawtooth signal with fundamental frequency 5Hz and amplitude ±0.5, and then their spectrum. b.

Plot continuous-time square wave 1 and square wave 2 with fundamental frequency 5Hz and duty cycle 0.5 separately, and then their spectrum. c.

Change the fundamental frequency and amplitude. Plot spectrum of continuous-time sinusoidal signal and sawtooth signal with fundamental frequency 10Hz and amplitude ±1. d.

Let the duty cycle be 0.5, plot the spectrum of continuous-time square wave 1 with fundamental frequency 10Hz and 20Hz separately; then let the fundamental frequency be 20Hz, plot the spectrum of continuous-time square wave 1 with duty cycle 0.25 and 0.75

1

Signals and Systems Experiment Guide

separately. Find out effects of parameter variation on spectrum of signals.

2. Spectrum of continuous-time periodic signals.

Run the “Signals and Systems Experiment Systems” and then “Spectrum Analysis”. Sketch the following signals. a. b. c. d.

Plot the sinc function wave and its spectrum with band-limit width 2Hz, 5Hz and 10Hz.

Plot the rectangular pulse signal and its spectrum with band-limit width 5Hz, 10Hz and 15Hz.

Change the width of first lobe of sinc function signal and find out effects of width variation on spectrum of the signal.

Change the fundamental frequency of rectangular pulse signal and find out effects of fundamental frequency variation on spectrum of the signal.

3. Composition of square wave.

Run the “Signals and Systems Experiment Systems” and then “Signal Analysis Demonstration”. Observe the process of composition of square wave. Square wave are composed by the odd harmonic components of sinusoidal signal. In this process, note the Gibbs phenomenon. It means that for any finite value of N, the peak amplitude of the ripples remains constant, as shown in Fig 1.1.

2

Signals and Systems Experiment Guide

Fig 1.1 Composition of square wave

1.3 Extension Problem

Specify the convergence conditions of Fourier transforms.

3

Signals and Systems Experiment Guide

Experiment 2 Signal Sampling

2.1 Aims of Experiment

1. Comprehend the process of signal sampling and reconstruction 2. Master the sampling theorem and conditions of signal reconstruction. 3. Understand the importance of sampling theorem.

4. Master the simulation methods using MATLAB/SIMULINK. 2.2 Principle of Experiment

The principle used in this experiment is sampling theorem. Under certain conditions, a continuous-time signal can be completely represented by and recoverable from knowledge of its values, or samples, at points equally spaced in time. In this course, sampling theorem is the base.

Much of the importance of the sampling theorem lies in its role as a bridge between continuous-time signals and discrete-time signals. The fact that under certain conditions a continuous-time signal can be completely recovered from a sequence of its samples provides a mechanism for representing a continuous-time signal by a discrete-time signal. In many cases, processing discrete-time signals is more flexible and is often preferable to processing continuous-time signals. The concept of sampling suggests an extremely attractive and widely employed method for using discrete-time system technology to implement continuous-time systems and process continuous-time signals.

Sampling Theorem:

Let x(t) be a band-limited signal with X(jω)=0 for ω>ωM. Then x(t)

is uniquely determined by its samples x(nT), n=0,±1, ±2,…, if ωs>2ωM, where 2ωs=π/T. Given these samples, we can construct x(t) by generating a periodic impulse train in which successive impulse have amplitudes that are successive sample values. This impulse train is then processed through an ideal lowpass filter with gain T and cutoff frequency greater than ωM and

4

Signals and Systems Experiment Guide

less than ωs−ωM. The resulting output signal will exactly equal x(t).

Fig. 2.1 shows the process of exact recovery of a continuous-time signal from its samples using an ideal lowpass filter. Fig.2.1(a) shows the system for sampling and reconstruction.

(a)

(b)

(c)

(d)

(e)

Fig 2.1 Exact recovery of a continuous-time signal from its samples using an

ideal lowpass filter: (a) system for sampling and reconstruction; (b) representative spectrum for x(t); (c) corresponding spectrum for xp(t); (d) ideal

lowpass filter to recover X(jω)from Xp(jω); (e) spectrum of xr(t).

5

Signals and Systems Experiment Guide

2.3 Contents of Experiment

1. Enter into experiment environment. Run the “Signals and Systems

Experiment Systems” and then “Signal Sampling”. Run “continuous-time signal sampling” and Fig.2.2 is shown. This system is based on the principle of sampling theorem.

Fig 2.2 Sampling experiment simulation models

2. Let the frequency of sampling function be 200rad/s and the fundamental frequency of signal source be 6rad/s. The cutoff frequency of butterworth LPF1 and LPF2 is 60rad/s. In this course, note the unit of physical variable. Then run the simulation model. After this, look at the spectrum display. Plot continuous-time signals and their spectrum, i.e. the signal source and its spectrum, the sampled signal and its spectrum and the recovered signal and its spectrum.

3. Let the frequency of sampling function be 200rad/s and the fundamental

frequency of signal source be 6rad/s. The cutoff frequency of butterworth LPF1 is 60rad/s and LPF2 is 250rad/s. In this course, note the unit of physical variable. Then run the simulation model. After this, look at the

6

Signals and Systems Experiment Guide

spectrum display. Plot continuous-time signals and their spectrum, i.e. the signal source and its spectrum, the sampled signal and its spectrum and the recovered signal and its spectrum. Compared with results in (2), discuss and analyze them.

4. Let the frequency of sampling function be 100rad/s and the fundamental frequency of signal source be 60rad/s. The cutoff frequency of butterworth LPF1 and LPF2 is 65rad/s. In this course, note the unit of physical variable. Then run the simulation model. After this, look at the spectrum display. Plot continuous-time signals and their spectrum, i.e. the signal source and its spectrum, the sampled signal and its spectrum and the recovered signal and its spectrum. Compared with results in (2) and (3), discuss and analyze them.

2.4 Extension Problem

In this experiment (2)(3)(4), specify which experiment can realize the

sampling and recovery of signals, which experiment is undersampling and reasons. Specify the conditions of signal sampling and recovery.

Note:

The characteristics of ideal LPF and butterworth LPF are shown in Fig.2.3.

-WWω-WWω

(a) Ideal LPF (b) Butterworth LPF

Fig 2.3 Characteristics of ideal LPF and butterworth LPF

7

Signals and Systems Experiment Guide

Experiment 3 System Characteristics

3.1 Aims of Experiment

1. Comprehend the characteristics of LTI systems in the time-domain and frequency-domain.

2. Master the system characteristics of first-order RC LPF and first-order RC HPF in the time-domain and frequency-domain.

3. Master the effects of parameters on the system characteristics of first-order RC LPF and first-order RC HPF.

4. Comprehend the characteristics of second-order RLC system. 3.2 Principle of Experiment

1. A Simple RC Lowpass Filter

Electrical circuits are widely used to implement continuous-time filtering operations. A first-order RC circuit shown in Fig.3.1 can be used to perform either a lowpass or highpass filtering operation, depending on what we take as the output signal. Suppose that we take the capacitor voltage as the output, this circuit is a simple RC lowpass filter.

Fig 3.1 A simple RC lowpass filter circuit

The frequency response of H(jω)of this system is:

H(jω)=

1

1+jωRC

The magnitude and phase of the LPF frequency response are shown in Fig.3.2. In this figure, τ=RC.

8

Signals and Systems Experiment Guide

2⎤20lgH(jω)=−10lg⎡1(ωτ)+⎣⎦

(H(jω)=−tg−1(ωτ)

Fig 3.2 Frequency response of the RC LPF

Impulse response and step response of the system are:

1−t/RC

h(t)=eu(t)

RC

s(t)=[1−e−t/RC]u(t)

Impulse response and step response of the system are shown in Fig.3.3.

9

Signals and Systems Experiment Guide

Fig 3.3 Impulse response and step response of the RC LPF

2. A Simple RC highpass Filter

A first-order RC circuit shown in Fig.3.1 can be used to perform either a lowpass or highpass filtering operation, depending on what we take as the output signal. Suppose that we take the resistor voltage as the output, this circuit is a simple RC highpass filter, as shown in Fig.3.4.

Fig 3.4 A simple RC highpass filter circuit

The frequency response of H(jω)of this system is:

G(jω)=

jωRC

1+jωRC

The magnitude and phase of the HPF frequency response are shown in Fig.3.5.

10

Signals and Systems Experiment Guide

In this figure, τ=RC.

2⎤20lgH(jω)=−10lg⎡1(ωτ)+⎣⎦

(H(jω)=−tg−1(ωτ)

Fig 3.5 Frequency response of the RC HPF

The step response of the highpass filter is:

s(t)=e−t/RCu(t)

3.3 Contents of Experiment

1. Enter into experiment environment. Run the “Signals and Systems Experiment Systems” and then “System Characteristics”. 2. System characteristics in the time-domain

Run “System Characteristics in the Time-domain” . a. First-order LTI system characteristics.

Run “First-order System Characteristics in the Time-domain”. Let input

11

Signals and Systems Experiment Guide

signal is square wave, and plot input signal, output signal and magnitude of the frequency response for the first-order LTI system 1 and 2 with R=10Ω and C=0.01F. Run the simulation models. Then change parameters with R=100Ω and C=0.01F and plot corresponding signals. Compare these simulation results.

b. Second-order RLC system characteristics.

Run “Second-order System Characteristics in the Time-domain”. Let input signal is square wave, and plot input signal, output signal and magnitude of the frequency response for the Second-order RLC system with R=10Ω, C=0.01F and L=1H. Then change RLC parameters and find out the variation of frequency response.

3. System characteristics in the frequency-domain.

Run “System Characteristics in the Frequency-domain” and select the first-order RC system.

Select first-order lowpass system. Describe the model of first-order lowpass system and analyze the system. Plot the magnitude and phase for the frequency response of the lowpass system in the following parameters:

R=10Ω, C=1 F; R=1Ω, C=1 F; R=0.1Ω,C=1 F.

Select first-order highpass system. Describe the model of first-order

highpass system and analyze the system. Plot the magnitude and phase with above parameters.

3.4 Extension Problem

In this experiment, determine the frequency response H(jω)of the RC

lowpass and highpass filters through mathematic models and specify how the first-order system magnitude characteristic is varied with cutoff frequency.

12

Signals and Systems Experiment Guide

Experiment 4 Analysis of Continuous-time System in

the s-domain

4.1 Aims of Experiment

1.Master the Laplace transform and the inverse Laplace transform of continuous-time LTI system.

2. Master pole-zero plot of continuous-time LTI system.

3.Comprehend unit impulse response and frequency response of continuous-time LTI system and master solution methods.

4.2 Contents of Experiment

1.Using corresponding MATLAB functions, determine the Laplace transform for the following function of time, verify results using inverse Laplace transform function and demonstrate results with the theoretical calculation.

[e−αtcosω0t]u(t)

2.Consider the following stable system:

dy(t)(a)+3y(t)=3x(t)

dt

(b)

d2y(t)dy(t)d2x(t)3+4+y(t)=+5x(t) 22

dtdtdt

Using MATLAB, determine pole-zero plot, curves of unit impulse response and frequency response.

3.Determine the pole-zero plot, the unit impulse response and frequency response of stable system of part 2, and demonstrate results through theoretical calculation.

4.3 Expansion problem:

13

Signals and Systems Experiment Guide

Can you judge whether or not the system is stable according to the system pole-zero plot using MATLAB? If you can, give your reasons. At the same time, determine whether the system is causal.

4.4 Requirement:

1. Summarize aims and principle of the experiment.

2.Determine the Laplace transform of functions of continuous-time using MATLAB. Compare results of theoretical calculation with results using MATLAB.

3.Determine pole-zero plot and curves of unit impulse response and frequency response using MATLAB. Compare results of theoretical calculation with results using MATLAB. 4.Generalize experiment conclusions. 5.Answer expansion problems.

4.5 Demonstration:

Example4_1: Determine the Laplace transform of f(t)=e−tsin(at)u(t) and

s2

. Using laplace and ilaplace the inverse Laplace transform of F(s)=2

s+1function in MATLAB.

Now let us see how MATLAB can analyze this problem. For this example, three steps are following: Step 1. Create a new m-file.

Step 2. Determine the Laplace transform of the system using the laplace function.

Step 3.Determine the inverse Laplace transform of the system using the

ilaplace function.

Example4_1.m:

14

Signals and Systems Experiment Guide

f1= sym('exp(-t)*sin(a*t)'); laplace(f) can determine F1=laplace(f1) Laplace transform of function F2=sym('s^2/(s^2+1)'); f2=ilaplace(F2) ilaplace(F) can determine the inverse Laplace transform of F

Key:

F1=a/((s+1)^2+a^2)

f2=Dirac(t)−sin(t)

Dirac(t) is the Dirac Delta function in the Symbolic Math Toolbox and it means

δ(t)function.

Example4_2: The system transfer function is H(s)=

Determine the system pole-zero plot using MATLAB.

1s3+2s2+2s+1

.

(1) Determine curves of unit impulse responseh(t)and frequency responseH(jω)using MATLAB.

(2) Determine whether this system is stable.

Now let us see how MATLAB can analyze this problem, for this example, five steps are following: Step 1. Create a new m-file.

Step 2. Input the transfer function of the system into MATLAB.

Step 3. Determine the pole-zero plot of the system using pzmap function. Step 4. Determine the unit impulse responseh(t) of the system using impulse

function.

Step 5. Determine the frequency responseH(jω) of the system using freqs function.

15

Signals and Systems Experiment Guide

Example4_2.m:

num=[1]; Specify transfer functions or convert den=[1 2 2 1]; LTI model to transfer function form sys=tf(num,den); poles=roots(den); figure(1); pzmap(sys) plots the pole-zero map of the pzmap(sys); continuous- or discrete-time LTI model sys. t=0:0.02:10; h=impulse(num,den,t); Compute the impulse figure(2); response of LTI models plot(t,h); xlabel('t(s)'); ylabel('h(t)'); title('Impulse Response'); [h,w] = freqs(b,a) automatically [H,w]=freqs(num,den); picks a set of 200 frequency points w on which to compute the figure(3); plot(w,abs(H)); frequency response h. xlabel('ang.freq.\\omega(rad/s)'); ylabel('|H(j\\omega)|'); title('Magnitude Response'); key:

Fig 4.1 Pole-zero plot

16

Signals and Systems Experiment Guide

Fig 4.2 Curve of impulse response

Fig 4.3 Curve of frequency response

17

Signals and Systems Experiment Guide

Experiment 5 Analysis of Discrete-time System in the

z-domain

5.1 Aims of Experiment

1.Master the z-transform and the inverse z-transform of discrete-time LTI system.

2.Master pole-zero plot of discrete-time LTI system.

3.Comprehend unit impulse response and frequency response of discrete-time LTI system and master solution methods.

5.2 Contents of Experiment

1.Using corresponding MATLAB functions, determine the z-transform for the following function, verify results using inverse z-transform function and demonstrate results with the theoretical calculation.

[cosω0n]u[n]

2.Consider the following system:

(a)

y[n]+3y[n−1]=3x[n]

(b)y[n]−

11

y[n−1]=x[n]−x[n−1] 22

Using MATLAB, determine pole-zero plot, curves of unit impulse response and frequency response.

3.Determine the pole-zero plot, the unit impulse response and frequency response of the system of part 2, and demonstrate results through theoretical calculation.

5.3 Expansion problem:

Can you judge whether or not the system is stable according to the system

18

Signals and Systems Experiment Guide

pole-zero plot using MATLAB? If you can, give your reason. At the same time, determine whether the system is causal.

5.4 Requirement:

1. Summarize aims and principle of the experiment.

2. Determine the z-transform of function of discrete-time using MATLAB. Compare results of theoretical calculation with results in MATLAB. 3. Determine pole-zero plot and curves of unit impulse response and frequency response using MATLAB. Compare results of theoretical calculation with results in MATLAB. 4. Generalize experiment conclusions. 5. Answer expansion problems.

5.5 Demonstration:

Example5_1: Determine the z-transform of f[k]=cos(at)u[k] and the inverse

z-transform of F(z)=MATLAB.

Now let us see how MATLAB can analyze this problem, for this example, three steps are following: Step 1. Create a new m-file.

Step 2. Determine the z-transform using the ztrans function. Step 3. Determine the inverse z-transform using the iztrans function.

Example5_1.m:

1

, Using the ztrans and iztrans function in 2

(1+z)

19

Signals and Systems Experiment Guide

f1= sym('cos(a*k)'); F1=ztrans(f1) F2=sym('1/(1+z)^2'); f2=iztrans(F2) ztrans(f) can determine z-transform of function f iztrans(F) can determine the inverse z-transform of function F Key:

F1=(z−cos(a))*z/(z^2−2*z*cos(a)+1)

f2=charfun[0](n)−(−1)^n+(−1)^n*n

Charfun[0](n) means the δ[n] function.

Example5_2:

The system transfer function is

z−1+2z−2+z−3

H(z)=. −1−2−3

1−0.5z−0.005z+0.3z

(1) Determine the pole-zero plot of the system using MATLAB.

(2)Determine curves of unit impulse responseh(t)and frequency responseH(jω)using MATLAB. (3)Determine whether this system is stable.

Now let us see how MATLAB can analyze this problem, for this example, four steps are following: Step 1. Create a new m-file.

Step 2. Determine the pole-zero plot of the system using zplane function. Step 3. Determine the unit impulse responseh(t) of the system using impz function.

Step 4. Determine the frequency responseH(jω) of the system using freqz function.

Example5_2.m:

20

Signals and Systems Experiment Guide

b=[0 1 2 1]; a=[1 -0.5 -0.005 0.3]; figure(1); zplane(b,a) plots the pole-zero map of the zplane(b,a); discrete-time LTI model system. num=[0 1 2 1]; den=[1 -0.5 -0.005 0.3]; h=impz(num,den); Compute the impulse response of quantized filters figure(2); stem(h); xlabel('k'); ylabel('h[k]'); title('Impulse Response'); [h,w] = freqz(b,a) returns the frequency [H,w]=freqz(num,den); response vector h and the corresponding figure(3); frequency vector w for the quantized filter plot(w/pi,abs(H)); hq. freqz uses the transfer function associated xlabel('ang.freq.\\omega(rad/s)'); with the quantized filter to calculate the frequency response of the filter. ylabel('|H(e^j^\\omega)|'); title('Magnitude Response'); key:

Fig 5.1 Pole-zero plot

21

Signals and Systems Experiment Guide

Fig 5.2 Curve of impulse response

Fig 5.3 Curve of frequency response

22

Signals and Systems Experiment Guide--Appendix

附 录 A 信号与系统实验系统操作步骤

1、 打开计算机电源开关,进入WINDOWS操作系统

2、 在桌面上,用鼠标左键双击MATLAB图标或“开始”程序下的MATLAB,就进入MATLAB的软件操作系统的MATLAB的命令窗口。

3、进入信号实验所在的目录,在MATLAB的命令窗口下输入XHSY,便可启动《信号与系统》实验教学系统的引导页面(见图A.1),用鼠标左键单击“帮助”按钮,就可阅读有关实验的说明。在信息窗口上用鼠标左键单击“关闭”图标,将退出信息窗口。

图A.1《信号与系统》实验的引导页面

4、在引导页面上单击“开始”图标即可进入《信号与系统》实验的主页面(见图A.2)。在页面上,可以看到《信号与系统》实验的五大部分:[信号分析]、[信号抽样]、[系统特性]、[系统仿真]及[滤波器设计]。每一部分都有相应的信息说明。用鼠标单击“信息”图标,就可阅读有关的信息;单击相应图标就可进入相应的实验。

23

Signals and Systems Experiment Guide--Appendix

图A.2《信号与系统》实验主页面

此外,主页面上还提供了三种可选择的功能框:[关于教学系统],[教学系统入门]及[退出教学系统]。用鼠标左键单击前两种功能框,可阅读相应的背景说明,单击[退出教学系统]就回到MATLAB的命令窗口。

24

Signals and Systems Experiment Guide--Appendix

附 录 B MATALB在信号与系统中的应用

一、 连续信号和离散信号的MATLAB表示

1 连续信号的MATLAB表示

MATLAB提供了大量用以生成基本信号的函数,比如最常用的指数信号、正弦信号等就是MATLAB的内部函数,即不需要安装任何工具箱就可以调用的函数。 a. 指数信号

指数信号Ae在MATLAB中可用exp函数表示,其调用形式为:

at

Y=A*exp(a*t)

例如图B.1所示指数衰减信号的MATLAB源程序如下(取A=1,a=-0.4):

%Program1_1Decaying exponential signal A=1;a=-0.4; t=0:0.01:10; ft=A*exp(a*t); plot(t,ft);grid on; b. 正弦信号

正弦信号Acos(ω0t+ϕ)和Asin(ω0t+ϕ)分别用MATLAB的内部函数cos和sin表示,其调用形式为:

Acos(ω0t+phi) Asin(ω0t+phi)

例如图B.2所示正弦信号的MATLAB源程序如下(A=1,ω0=2π,ϕ=π/6):

%Program1_2 Sinusoidal signal A=1;w0=2*pi;phi=pi/6; t=0:0.001:8; ft=A*sin(w0*t+phi);

25

Signals and Systems Experiment Guide--Appendix

plot(t,ft);grid on;

图B.1 单边指数衰减信号 图B.2 正弦信号

除了内部函数外,在信号处理工具箱(Signal Processing Toolbox)中还提供了诸如抽样函数,矩形脉冲信号等在信号处理中常用的信号 c. 抽样函数

抽样函数Sa(t)在MATLAB中用sinc函数表示,其定义为: sinc(t)=sin(πt)/(πt) 其调用形式为: y=sinc(t)

例如图B.3所示抽样函数MATLAB源程序如下:

%Program1_3 Sample function t=-3*pi:pi/100:3*pi; ft=sinc(t/pi); plot(t,ft);grid on; d. 矩形脉冲信号

矩形脉冲信号在MATLAB中用rectpuls函数表示,其调用形式为: y=rectpuls(t,width)

用以产生一个幅值为1、宽度为width、相对于图t=0点左右对称的矩形波信号。例如图B.4所示以t=2T为对称中心的矩形脉冲信号的MATLAB源程序如下:

%Program1_4 Rectangular pulse signal

26

Signals and Systems Experiment Guide--Appendix

t=0:0.001:4; T=1;

ft=rectpuls(t-2*T,2*T);

plot(t,ft);grid on;axis([0 4 -0.5 1.5]);

图B.3 抽样函数 图B.4 矩形波信号

2

离散信号的MATLAB表示

对于任意离散序列f[k],需要两个向量来表示:一个表示k的取值范围。另一个表

示序列的值。例如f[k]={2,1,1,-1,3,0,2}(这里“1”)表示k=0所对应的位置,下同)可用MATLAB表示为:

k=-2:4;f=[2,1,1,-1,3,0,2];

若序列是从k=0开始,则只用一个向量f就可以表示该序列了。由于计算机内存的,MATLAB是无法表示一个任意的无穷序列。 a. 指数序列

离散指数序列的一般形式为a,可以用MATLAB中的数组幂运算(即点幂运算)

k

a.∧k来实现。

例如图B.5所示指数衰减序列的MATLAB源程序如下(取A=1,a=-0.6):

%Program1_5 Exponential sequence k=0:10;A=1;a=-0.6; fk=A*a.^k;

27

=

Signals and Systems Experiment Guide--Appendix

stem(k,fk);grid on;

改变程序中a值可以得到指数递增序列等其他指数序列。 b. 正弦序列

离散指数序列的MATLAB表示与连续信号类似,只不过是用stem函数而不是用plot函数来画出序列的波形。

例如图B.6所示正弦序列sin(π/6)k的MATLAB源程序如下:

%Program1_6 Discrete-time sinusoidal signal k=0:39; fk=sin(pi/6*k); stem(k,fk);grid on;

图B.5 指数衰减序列 图B.6 正弦序列

c. 单位冲激序列

单位冲激序列定义为: δ[k]=⎨

⎧1k=0

={…0,0,1,0,0,…} ⎩0k≠0

借助MATLAB中的全零矩阵zeros。全零矩阵zeros(1,N)产生一个有N个零组成的行向量,对于有限区间的δ[k]可以在MATLAB中表示为:

%Program1_7 Unit impulse sequence

k-50:50;

28

Signals and Systems Experiment Guide--Appendix

delta[zeros(1,50),1,zeros(1,50)]; stem(k,delta); d. 单位阶跃序列

单位阶跃序列的定义为: u[k]=⎨

⎧1k≥0

={…,0,0,1,1,1,…} 0k0<⎩

借助MATLAB中的单位矩阵函数(全一矩阵函数)ones来表示。单位矩阵ones(1,N)产生一个有N个“1”组成的行向量,对于有限区间的u[k]可以表示为:

%Program1_8 Unit step sequence k=-50:50;

uk=[zeros(1,50),ones(1,51)]; stem(k,uk);

二 、 时域分析的MATLAB实现

1. 连续时间系统的零状态响应、冲激响应和阶跃响应 a. 连续时间系统的零状态响应

=LTI连续时间系统以常系数微分方程描述,系统的零状态响应可以通过求初始状态为零的微分方程得到。在MATLAB中,控制系统工具箱提供了一个用于求解零初始条件微分数值解的函数lsim,其调用形式为:

y=lsim(sys,f,t)

式中,t表示计算系统响应的抽样点向量,f是系统输入信号向量,sys是LTI系统

模型,用来表示微分方程、差分方程、状态方程。在求解微分方程时,微分方程的LTI系统模型sys要借助MATLAB中的tf函数来获得,其调用形式为: Sys=tf(b,a)

式中,b和a分别为微分方程右端和左端各项的系数向量。例如对于三阶微分方程:

a3y'''(t)+a2y''(t)+a1y'(t)+a0y(t)=b3f'''(t)+b2f''(t)+b1f'(t)+b0f(t)

29

Signals and Systems Experiment Guide--Appendix

可以用下列MATLAB语句:

a=[a3,a2,a1,a0];

b=[b3,b2,b1,b0]; sys=tf(b,a);

来获得LTI模型。

b. 连续时间系统的冲激响应和阶跃响应

在MATLAB中,求解系统冲激响应可应用控制系统工具箱提供的函数impulse,求解阶跃响应可利用函数step,其调用形式为: y=impulse(sys,t)

y=step(sys,t)

式中,t表示计算系统响应的抽样点向量,sys是LTI系统模型。 例如,系统的输入信号为f(t)=10δ(t),系统的微分方程为:

d2y(t)dy(t)

2 ++100y(t)=10δ(t)

dt2dt

计算y(t)的源程序如下:

%Program 2_1 Impulse response of LTI system ts=0;te=5;dt=0.01; sys=tf([10],[1 2 100]); t=ts:dt:te; y=impulse(sys,t);

plot(t,y);xlabel('t(sec)');ylabel('y(t)');grid on; 程序运行结果如图B.7所示。

30

Signals and Systems Experiment Guide--Appendix

图B.7 系统的冲激响应

2.离散时间系统的冲激响应和阶跃响应

在MATLAB中,求解离散时间系统单冲激响应,可应用信号处理工具箱提供的函

数impz,其调用形式为:

h=impz(b,a k)

式中,b=[b0,b1,b2,\",bM]、a=[a0,a1,a2,\",aM]分别是差分方程左、右端的系数向量,k表示冲激响应的时间采样点数或范围(若省略,则由系统自行决定),h就是系统的单位冲激响应(如果没有输出参数,直接调用impz(b,a,k),则MATLAB将在当前绘图窗口中自动画出系统单位冲激响应的图形)。对于MATLAB6.x及以上版本,在信号处理工具箱中还提供了求解离散时间系统单位阶跃响应的函数stepz,其调用形式为:

h=stepz(b,a,k)

式中参数与impz函数基本相同(其中k仅指阶跃响应的时间采样点数),如果没有输出参数,直接调用stepz(b,a,k),则MATLAB也将会在当前绘图窗口中自动画出系统单位阶跃响应的图形。

31

Signals and Systems Experiment Guide--Appendix

3.卷积的计算

卷积是用来计算系统零状态响应的有力工具,例如:对于连续时间系统,有

y(t)=x(t)*h(t),其中h(t)为系统传递函数(即冲激响应);对于离散时间系统,有y[n]=x[n]*h[n],其中h[n]为系统传递函数(即单位冲激响应)。

MATLAB信号处理工具箱提供了一个计算两个离散序列卷积的函数conv,其调用形式为:

c=conv(a,b)

式中,a,b分别为待卷积的两序列的向量表示,c是卷积结果。向量c的长度为向量a,b的长度之和减1,即length(c)=length(a)+length(b)-1。事实上,研究conv的函数代码conv.m可知,conv函数实质就是利用filter函数来实现的。

例如,已知序列x[n]={1,2,3,4;n=0,1,2,3,},y[n]={1,1,1,1,1;n=0,1,2,3,4},利用MATLAB计算x[n]*y[n]并画出卷积结果。源程序如下:

%Program 2_2 Convolution of two sequences x=[1,2,3,4];y=[1,1,1,1,1];z=conv(x,y);

subplot(3,1,1);stem(0:length(x)-1,x);ylabel('x[n]'); subplot(3,1,2);stem(0:length(y)-1,y);ylabel('y[n]');

subplot(3,1,3);stem(0:length(z)-1,z);ylabel('x[n]*y[n]');xlabel('n');

图B.8 两序列的卷积计算

32

Signals and Systems Experiment Guide--Appendix

三. 频域分析的MATLAB实现

1. 系统的频域特性分析 a. 连续时间系统的频率特性

当连续时间系统的频率响应H(jω)是jω的有理多项式时,即:

B(jω)b(1)(jω)N+b(2)(jω)N−1\"+b(N+1)

H(jω)==

A(jω)a(1)(jω)M+a(2)(jω)M−1\"+a(M+1)

或写为H(s)的形式:

NN−1

\"+b(N+1) H(s)=B(s)=b(1)s+b(2)s

MM−1

A(s)a(1)s

+a(2)s\"+a(M+1)

MATLAB信号工具箱提供的freqs函数可直接计算系统的频率响应,其一般调用形式为:

H=freqs(b,a,w)

式中的b即为H(jω)有理多项式中分子多项式的系数向量,a即为分母多项式的系数向量,w为需要计算的H(jω)的频率抽样点响亮(w中至少需包含2个频率点,w的单位为rad/s)。如果没有输出参数,直接调用freqs(b,a,w),则MATLAB会在当前绘图窗口中自动画出幅频和相频响应曲线图形。另一种调用形式为:

[H,w]=freqs(b,a,N)

它表示由MATLAB自动选择一组N个频率点来计算响应。N的缺省值为200。

b. 离散时间系统的频率特性

MATLAB信号工具箱的freqz函数可直接计算离散系统的频率响应,其一般的调用形式为:

H=freqz(b,a,w)

式中的b即为H(ejΩ)有理式中分子多项式的系数向量,a即为分母多项式的系数向量,

w为需要计算的H(ejΩ)的频率抽样点向量(w中至少包含2个频率点,w的单位为rad/s抽样,通过常数取在0和π之间)。如果没有输出参数,直接调用freqz(b,a,w),则MATLAB会在当前绘图窗口中自动画出幅频和相频响应曲线图形。另一种调用形式为:

[H,w]=freqz(b,a,N)

33

Signals and Systems Experiment Guide--Appendix

它表示有MATLAB选择在单位圆的上半周上均等间距分布的N个频率点来计算其频率响应。N的缺省值为512。

2. 连续时间系统的s域分析

a. 利用MATLAB实现部分分式展开

利用MATLAB中的residue函数可得复杂的s域表示式F(s)的部分分式展开,其调用形式为

[r,p,k]=residue(num,den)

其中,num,den分别为F(s)分子多项式和分母多项式的系数向量(num=numerator,

den=denominator),r为所得部分分式展开式的系数向量,p为极点,k为分式的直流分量。

b. 利用MATLAB计算H(s)的零极点

系统函数H(s)通常是一个有理分式,其分子和分母均为多项式。利用roots函数,求出分子和分母多项式的根,即可计算出H(s)的零极点。例如,多项式

N(s)=s4+2s2+4s+5的根可由下列语句求出:

N=[1 0 2 4 5]; r=roots(N);

运行结果为(r为一列向量):

r'=0.8701-1.7048i 0.8701+1.7048i -0.8701-0.7796i -0.8701+0.7796i

在MATLAB中还有一种更简便的方法来画系统函数H(s)的零极点分布图,即应用

MATLAB中pzmap函数来画,其调用形式为:

pzmap(sys)

它在表示画出有sys所描述的系统的零极点分布图。而LTI系统模型sys借助tf函数获得,其调用形式为:

sys=tf(b,a)

式中,b和a分别为系统函数H(s)分子多项式和分母多项式的系数向量。

c. 利用MATLAB计算Laplace正反变换

34

Signals and Systems Experiment Guide--Appendix

MATLAB的符号数学工具箱中提供了计算Laplace正反变换的函数laplace 和ilaplace,它们比前面介绍过的部分分式展开法的residue函数更为通用,功能更为强大,其调用形式为:

F=laplace(f) f=ilaplace(F)

上述两式中,右端的f 和F应分别为系统的时域表示式和s域表示式,可用函数sym来实现,其调用形式为:

S=sym(A)

式中,A为待分析的表示式的字符串,S为符号数字或变量。注意,符号数学工具箱函数给出的结果是解析表达式(其中可以带上尚为未知数的参数符号),而且非一般的以向量来表示的数值结果。

例如,利用MATLAB中的laplace函数求 f(t)=esin(at)u(t)的Laplace变换,其源程序如下:

−t

%Program 2_3 Laplace transform using laplace function f=sym('exp(-t)*sin(a*t)'); F=laplace(f); 运行结果为:

F=a/(s+1)^2+a^2 即有:

L{esin(at)u(t)}=

−t

a

22

(s+1)+a

3.离散时间系统的z域分析

a. 利用MATLAB实现z域的部分分式展开

离散系统的z域表示式通常可用下列有理分式来表示:

35

Signals and Systems Experiment Guide--Appendix

b0+b1z−1+b2z−2+\"+bmz−mnum(z)

=F(z)=

a0+a1z−1+a2z−2+\"+anz−nden(z)

为了能从系统的z域表示式方便地得到其时域表示式,可将F(z)展开成部分分式之

MATLAB的信号处理工具箱提供了一个对F(z)进行部分和的形式,再对其求z反变换。分式展开的函数residuez,其调用形式为:

[r,p,k]=residuez(num,den)

式中,num 和den分别为F(z)的分子多项式和分母多项式的系数向量,r为部分分式的系数向量,p为极点向量,k为多项式的系数向量。

b. 利用MATLAB计算H(z)的有理分式表示为:

b(1)zm+b(2)zm−1+\"+b(m+1)

H(z)=

a(1)zn+a(2)zn−1+\"+a(n+1)

那么系统函数的零点和极点可以通过roots函数来得到,也可借助tf2zp函数来直接得到,其调用形式为:

[z,p,k]=tf2zp(b,a)

式中,b和a分别为上述H(z)有理分式中的分子多项式和分母多项式的系数向量,该函数的作用是将上述H(z)有理分式表示式转换为用零点、极点和增益常数组成的表示式,即:

H(z)=k

(z−z(1))(z−z(2))\"(z−z(m))

(z−p(1))(z−p(2))\"(z−p(n))

若要获得系统函数H(z)的零极点分布图,可直接应用zplane函数,其调用形式为:

zplane(b,a)

式中,b和a分别为上述系统函数H(z)有理分式表示式中的分子多项式和分母多项式的系数向量,该函数的作用是在z平面上画出单位圆及系统的零点和极点。

另外,如果已知系统函数H(z)的多项式分式或者有理分式形式,求系统的单位冲激响应h[k]和频率响应H(e

jΩ

),则可应用impz和freqz函数。

c. 利用MATLAB计算H(z)的有理分式表示为:

36

Signals and Systems Experiment Guide--Appendix

MATLAB的符号数学工具箱提供了计算z正变换的函数ztrans和z反变换的函数iztrans,其调用形式为;

F=ztrans(f) f=iztrans(F)

上述两式中,右端的f和 F应分别为时域表示式和z域表示式的符号表示,可应用

函数sym来实现,其调用形式为:

S=sym(A)

式中,A为待分析的表示式的字符串,S为符号化的数字或变量。

例如,利用MATLAB中的ztrans函数求f[k]=cos(ak)u[k]的z变换。源程序如下:

%Program 2_4 Ztransform using function f=sym('cos(a*k)'); F=ztrans(f); 程序运行结果为:

F=(z-cos(a))*z/(z^2-2*z*cos(a)+1) 即有:

Z{cos(ak)u[k]}=

z[z−cos(a)]

2

z−2zcos(a)+1

37

Signals and Systems Experiment Guide--Appendix

附 录 C 实验报告书写要求

在实验教学过程中,书写实验报告是实验教学的重要环节,书写实验报告的过程,是实验思路再梳理的过程,是深化理解相应实验理论知识的过程,也是科学实验研究的要求,同时也是培养科学的研究作风的重要途径。书写实验报告分为预习报告和最终实验报告。

z 预习报告书写要求

预习报告主要内容包括以下五点:

1.实验名称

每次实验都有实验项目名称,写出本次实验的项目名称。

2.实验目的

实验作为教学的一个重要环节,其目的在于更深入地理解和掌握课程教学中的有关基本概念,应用基本技术解决实际问题,从而进一步提高分析问题和解决问题的能力。因此,当着手做一个实验的时候,必须明确实验的目的,以保证达到课程所指定的基本要求。

3.实验内容

实验的目的是要通过解决一些具体问题来达到的。因此,在实验报告中,实验内容是指本次实验中实际完成的内容。在给出的每一个实验题目中,一般都提出一些具体要求,其中有些具体要求是为了达到实验目的而提出的。所以,实验内容中不仅有具体的实验题目,还应包括具体要求。

4.理论分析

本部分包括是指根据实验内容,分析实验内容的理论结果,只有分析出来实验的理论结果,我们完成的实验结果才能知道对不对,这个过程也是对实验内容的更深理解的过程。

5.设计说明

设计说明包括设计思路、流程图、设计程序或者搭建的仿真电路等。

38

Signals and Systems Experiment Guide--Appendix

z 最终实验报告书写要求

在预习报告的基础上加上以下四部分内容就构成了最终实验报告。

1.实验结果

每次实验都会有实验结果产生,我们应对实验结果进行客观的描述,比如实验数据、实验仿真图形,我们可以用列表和图形表示实验结果,实验结果必须真是可靠,不可杜撰。

2.实验分析

本部分是指对实验结果的分析,可以根据实验的理论分析和实验结果给出本次实验的结论,如果实验结果和理论分析有误差,要对误差进行比较的分析,说明原因。如果实验结果表明实验结果有问题,要分析出是那儿出了问题,并分析实验设计的优缺点。

3.思考题的回答

根据老师的安排回答实验指导书及老师布置的思考题。

4.实验过程中碰到的问题及解决方法

每次实验都会碰到这样、那样的问题,同学们是如何解决的,应该把它记录下来。

39

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