Docsity

Discrete-Time Systems: Experiment 1 - Linear Systems and Discrete Approximation, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 1563 Fall, 2009
EXPERIMENT 1, DISCRETE-TIME SYSTEMS: Exercises
Homework 0 DUE on Wednesday, September 2
Homework 1 DUE on Monday, September 14
Exercises Report DUE before lab on Wednesday, September 16
Objective
The purpose of this experiment is to review the properties of linear systems and analyze
some of the differences between real continuous systems and discrete-time representations of
continuous systems.
Some Comments on defining linear systems in MATLAB
You can define a system in MATLAB by directly specifying coefficients of the defining
equation (differential or difference) as the numerator and denominator of the transfer function or
by creating a "system object". System objects can be created using the command ‘tf’. For
example, for a continuous second-order system with input function x(t) and output function y(t)
defined by the differential equation
x5
dt
dx
y2
dt
dy
2
dt
yd
2
2
+=++
with transfer function
22
5
)(
)(
)( 2++
+
== ss
s
sX
sY
sH
you can use
num = [1 5]; % Coefficients of right-hand side of differential equation
den = [1 2 2]; % Coefficients of left-hand side of differential equation
ContinuousSystem = tf(num,den);
To create a discrete system from a continuous system, use 'tf' with the Laplace transfer
function coefficients to generate an object representing the continuous system. Then use 'c2d' on
the continuous system to generate an explicit discrete representation. For example, to
approximate ContinuousSystem, use
DiscreteSystem = c2d(ContinuousSystem,T);
where T is the sampling interval. This form of ‘c2d’ uses a default discretization, but the
command allows you to specify the method of discretization.
You can also specify a discrete system directly from its z-transform by
DiscreteSystem = tf(numz,denz,T);
where numz and denz represent the coefficients of the defining difference equation and T is the
pf3
pf4
pf5

Partial preview of the text

Download Discrete-Time Systems: Experiment 1 - Linear Systems and Discrete Approximation and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

ECE 1563 Fall, 2009 EXPERIMENT 1, DISCRETE-TIME SYSTEMS: Exercises Homework 0 DUE on Wednesday, September 2 Homework 1 DUE on Monday, September 14 Exercises Report DUE before lab on Wednesday, September 16

Objective

The purpose of this experiment is to review the properties of linear systems and analyze some of the differences between real continuous systems and discrete-time representations of continuous systems.

Some Comments on defining linear systems in MATLAB

You can define a system in MATLAB by directly specifying coefficients of the defining equation (differential or difference) as the numerator and denominator of the transfer function or by creating a "system object". System objects can be created using the command ‘tf’. For example, for a continuous second-order system with input function x(t) and output function y(t) defined by the differential equation

5 x dt

dx 2 y dt

dy 2 dt

d y 2

2

    • = +

with transfer function

s s

s X s

Ys H s

you can use

num = [1 5]; % Coefficients of right-hand side of differential equation den = [1 2 2]; % Coefficients of left-hand side of differential equation ContinuousSystem = tf(num,den);

To create a discrete system from a continuous system, use 'tf' with the Laplace transfer function coefficients to generate an object representing the continuous system. Then use 'c2d' on the continuous system to generate an explicit discrete representation. For example, to approximate ContinuousSystem, use

DiscreteSystem = c2d(ContinuousSystem,T);

where T is the sampling interval. This form of ‘c2d’ uses a default discretization, but the command allows you to specify the method of discretization.

You can also specify a discrete system directly from its z-transform by

DiscreteSystem = tf(numz,denz,T);

where numz and denz represent the coefficients of the defining difference equation and T is the

sampling interval. If you want to specify a discrete system without a specific sampling interval, set T = -1. For example, for a discrete second-order system with input sequence x[n] and output sequence y[n] defined by the difference equation

y[n] = 0.6 y[n-1] - 0.8 y[n - 2] + 0.5 x[n] + 0.25 x[n-1]

with transfer function

z 0. 6 z 0. 8

z 0. 5 z

  1. 5 1 0. 6 z 0. 8 z

1 0. 5 z

  1. 5 X(z)

Y(z) H( z) 2

2 1 2

1

− +

−

you can use

numz = [0.5 0.25]; % Coefficients of x[n] denz = [1 -0.6 0.8]; % Coefficients of y[n] DiscreteSystem = tf(numz,denz,-1);

Note that there is no time associated with this system.

The coefficients of a z-domain transfer function of a discrete system that approximates a given continuous system are different from the coefficients of the s-domain transfer function of the continuous system. The orders of the numerator and denominator may even be different. Discrete transfer functions in MATLAB are defined in terms of descending powers of z (as opposed to powers of z-1).

Some commands in MATLAB (like 'freqz' and 'filter') require num and den as arguments. Others (like 'impulse' ) can use either the system object (e.g., ‘ContinuousSystem’ or ‘DiscreteSystem’) or the defining equation coefficients, num and den. Still others require system objects.

You may find it convenient to create a function or a script to calculate and plot the impulse response and frequency response of a system. You use this operation many times in this and the next lab.

Section 1: Discrete approximation of continuous systems

In this section, you will develop a discrete representation for the continuous time first-order low-pass filter and determine its response to a square wave and sinusoids.

Procedure

  1. Use the forward difference approximation to the first derivative to obtain a difference equation corresponding to the RC filter with RC = 50 milliseconds (ms).

Δ t

y(t Δt) y(t ) dt

dy (The forwarddifferenceapproximationis

Define the impulse response as h[n] = y[n] for x[n] = δ[n] and y[n] = 0, n ≤ 0.)

(p = [ones(1,10) zeros(1,40)] or p = [ones(10,1); zeros(40,1)]). Verify that the results are what they should be by comparing to your analytic result from the pre-lab.

  1. Compute the output of the filter from Section 1 for the input x(t) = 5 sin (2π 8 t) u(t) (Section 1-4b) by convolving the 500 ms segment of the input with the filter impulse response from Section 1-3, using the convolution sum.

Report

Compare your results to the results in Section 1. How are the lengths of the impulse response, the input and the output related? What does the end section of the output function represent? Include a listing of your m-file in your report.

Section 3: Simulating Systems in MATLAB

In this section, you will use MATLAB functions to find the outputs for continuous and discrete versions of a first-order lowpass filter.

Procedure

  1. Use the MATLAB functions 'impulse' and 'step' to obtain impulse and step responses for the continuous first-order filter in Section 1. Plot the responses using the time series from MATLAB. (Check the function help files for the function syntax.)
  2. Use the MATLAB functions 'impulse' and 'step' to obtain impulse and step responses for the difference equation that you developed for your discrete approximation of the first- order filter from Section 1. Plot the responses using the time series from MATLAB.
  3. By now, you should have created a continuous system object to represent the continuous, first-order low-pass filter. Convert this system to a discrete system using the MATLAB function 'c2d' with T = 5 ms and the default discretization method. Find the impulse and step responses of this discrete system. Use ‘lsim’ to obtain the outputs for the first 3 inputs used in Section 1.

Report

  1. Compare the impulse and step responses to those from Sections 1 and 2.
  2. What type of approximation does MATLAB use to estimate the derivative? (Check the help system for ‘lsim’.) Verify that the difference equation coefficients obtained in step 3 above are the same as those obtained using the direct integration method discussed in lecture. (See page 9 of notes on “Continuous and Discrete Linear Systems” under “Notes on signals and systems”.)
  3. Compare the results of MATLAB’s simulation of the continuous first-order low-pass

filter (using ‘lsim’) to your discrete approximation in Section 1. Comment on differences and why they occur.

Section 4: Non-recursive Systems

Difference equations like the ones we have been using to represent the filters are called recursive. Note that the value of y for sequence value k+1 is defined in terms of the input x and the output y at sequence value k; hence, the values of y are determined recursively from earlier values of y.

For a non-recursive system, the output y is defined only in terms of the inputs and not in terms of previous values of y. An example commonly encountered in signal processing is the three-point smoother:

y(k) = 0.25x(k) + 0.5 x(k-1) + 0.25*x(k-2)

In this section, you will explore some of the properties of this system.

Procedure

  1. Plot the impulse response of this system.
  2. Find and plot the output of this system for the square wave and the random input signals that you used in Sections 1-4c and d above.
  3. The above version of the three-point smoother is causal because the output is defined in terms of current input and previous values of the input. A non-causal version is

y(k) = 0.25x(k+1) + 0.5 x(k) + 0.25*x(k-1)

Plot the impulse response for this system.

Report

  1. How do the outputs of this system compare to the outputs of the recursive systems studied above? Can you think of this system as a filter? What kind of filter?
  2. Why is the system in part 3 non-causal? What does that imply about your ability to use this system to process a signal in real-time?
  3. What is the overall gain of this system? That is, what is the output for a constant-valued (dc) input signal, say x[k] = 0.5 for all k?