Lab 2
Lab 2
2.1 Introduction
A discrete-time system is anything that takes a discrete-time signal as input and generates a discrete-
time signal as output. The concept of a system is very general. It may be used to model the
response of an audio equalizer or the performance of the US economy.
In electrical engineering, continuous-time signals are usually processed by electrical circuits
described by differential equations. For example, any circuit of resistors, capacitors and inductors
can be analyzed using mesh analysis to yield a system of differential equations. The voltages and
currents in the circuit may then be computed by solving the equations.
The processing of discrete-time signals is performed by discrete-time systems. Similar to the
continuous-time case, we may represent a discrete-time system either by a set of difference equations
or by a block diagram of its implementation. For example, consider the following difference
equation.
𝑦(𝑛) = 𝑦[𝑛 − 1] + 𝑥[𝑛] + 𝑥[𝑛 − 1] + 𝑥[𝑛 − 2]
(2.1)
This equation represents a discrete-time system. It operates on the input signal x[n] to produce the
output signal y[n]. This system may also be defined by a system diagram as in Figure 2.1.
Mathematically, we use the notation y = S (x) to denote a discrete-time system S with input
signal x[n] and output signal y[n]. Notice that the input and output to the system are the complete
signals for all time n. This is important since the output at a particular time can be a function of past,
present and future values of x[n].
It is usually quite straightforward to write a computer program to implement a discrete-time
system from its difference equation. In fact, programmable computers are one of the easiest and most
cost effective ways of implementing discrete-time systems.
While equation (2.1) is an example of a linear time-invariant system, other discrete-time
systems may be nonlinear and/or time varying. In order to understand discrete-time systems, it is
important to first understand their classification into categories of linear/nonlinear, time-invariant/
time-varying, causal/noncausal, memoryless/with-memory, and stable/unstable. Then it is possible to
study the properties of restricted classes of systems, such as discrete-time systems which are linear,
time-invariant and stable.
EE323 Digital Signal Processing - Laboratory Manuals
Do the following:
For each of these three methods: 1) write a difference equation, 2) draw a system diagram, and 3)
calculate the impulse response.
Explain why methods (2.3) and (2.5) are known as moving averages.
arbitrary input signals. Then apply the differentiator and integrator to the following two signals for
−10 ≤ 𝑛 ≤ 20.
𝛿[n] − 𝛿[n − 5]
𝑢[n] − 𝑢[𝑛 − (𝑁 + 1)] with N = 10
HINT: To compute the function u(n) for −10 ≤ 𝑛 ≤ 20, first set n = -10:20, and then use the
Boolean expression u = (n>=0).
For each of the four cases, use the subplot and stem commands to plot each input and output
signal on a single figure.
INLAB REPORT: Submit your Matlab code and softcopies containing the input and output signals.
Discuss the stability of these systems.
NOTE: In Matlab, when implementing a difference equation using a loop structure, it is very
good practice to pre-define your output vector before entering into the loop. Otherwise, Matlab
has to resize the output vector at each iteration. For example, say you are using a for loop to
filter the signal x[n], yielding an output y[n]. You can pre-define the output vector by issuing the
command y=zeros(1,N) before entering the loop, where N is the final length of y. For long
signals, this speeds up the computation dramatically.
Now use these functions to calculate the impulse response of each of the following 5 systems: S1, S2,
S1 (S2) (i.e., the series connection with S1 following S2), S2 (S1) (i.e., the series connection with S2
following S1), and S1 + S2.
INLAB REPORT: For each of the five systems, draw and submit a system diagram (use only delays,
multiplications and additions as in Figure 2.1). Also submit plots of each impulse response. Discuss
your observations.
INLAB REPORT: Draw a system diagram for the system S3, and submit plots of the impulse
responses for S3 and S3(S2).
HINTS:
1. You should try a variety of input signals until you find a counter-example.
2. When testing for time-invariance, you need to look at the responses to a signal and to its
delayed version. Since all your signals in MATLAB have finite duration, you should be very
careful about shifting signals. In particular, if you want to shift a signal x by M samples to the
left, x should start with at least M zeros. If you want to shift x by M samples to the right, x
should end with at least M zeros.
3. When testing for linearity, you may find that simple inputs such as the unit impulse do not
accomplish the task. In this case, you should try something more complicated like a sinusoid
or a random signal generated with the random command.
INLAB REPORT: State which system is non-linear, and which system is time-varying. Submit
plots of input/output signal pairs that support your conclusions. Indicate on the plots why they
support your conclusions.
INLAB REPORT: Submit your plots of the original and filtered exchange-rates. Discuss the
advantages and disadvantages of the two filters. Can you suggest a better method for initializing
the filter outputs?