3. Discrete-Time Signals
ο± A discrete signal will be denoted by x(n), in which the variable n is integer-
valued and represents discrete instances in time (Sequence of Number).
π₯(π) = { π₯(π) } = { . . . , π₯( β 1), π₯(0), π₯(1), . . . }
ο§ where the up-arrow indicates the sample at n = 0.
ο± In MATLAB we can represent a ο¬nite-duration sequence by a row vector
of appropriate values.
ο± For example, a sequence x(n) = { 2, 1, β 1, 0, 1, 4, 3, 7 } can be
represented in MATLAB by
ο± An arbitrary inο¬nite-duration sequence cannot be represented in
MATLAB due to the ο¬nite memory limitations.
3
β
β
4. Types Of Sequences
1. Unit sample sequence:
ο± For example, to implement
ο§ over the π1 β€ π0 β€ π2 interval, we will use the following MATLAB function.
4
5. Types Of Sequences (Cont.)
2. Unit step sequence:
ο± For example, to implement
ο§ over the π1 β€ π0 β€ π2 interval, we will use the following MATLAB function.
5
6. Types Of Sequences (Cont.)
3. Real-valued exponential sequence:
ο± For example, to generate π₯ π = 0.9 π , 0 β€ π β€ 10, we will need the
following MATLAB script:
6
7. Types Of Sequences (Cont.)
4. Complex-valued exponential sequence:
ο§ where Ο produces an attenuation (if <0) or ampliο¬cation (if >0) and Ο 0 is
the frequency in radians.
ο± For example, to generate π₯ π = π(2 + π3)π , 0 β€ π β€ 10, we will need
the following MATLAB script:
7
8. Types Of Sequences (Cont.)
5. Sinusoidal sequence:
ο§ where A is an amplitude and ΞΈ0 is the phase in radians.
ο± For example, to generate π₯ π = 3 πππ 0.1ππ +
π
3
+ 2 π ππ( 0.5ππ ),
0 β€ π β€ 10, we will need the following MATLAB script:
8
9. Types Of Sequences (Cont.)
6. Random sequences:
ο§ Many practical sequences cannot be described by mathematical
expressions like those above. These sequences are called random (or
stochastic) sequences and are characterized by parameters of the
associated probability density functions.
ο± In MATLAB two types of (pseudo-) random sequences are available.
ο§ The rand(1,N) generates a length N random sequence whose elements are
uniformly distributed between [0, 1].
ο§ The randn(1,N) generates a length N Gaussian random sequence with mean
0 and variance 1.
ο§ Other random sequences can be generated using transformations of the
above functions.
9
10. Types Of Sequences (Cont.)
7. Periodic sequence:
ο§ A sequence x(n) is periodic if x(n) = x(n + N), βn. The smallest integer N
that satisο¬es this relation is called the fundamental period. We will use
Λx(n) to denote a periodic sequence.
ο± To generate P periods of π₯(π) from one period { π₯(π), 0 β€ π β€ π β 1} ,we
can copy π₯(π) π times:
ο± But an elegant approach is to use MATLABβs powerful indexing
capabilities.
10
11. Operations On Sequences
1. Signal addition:
ο§ This is a sample-by-sample addition given by
ο± The following function, called the π πππππ function, demonstrates these
operations.
11
12. Operations On Sequences (Cont.)
2. Signal multiplication:
ο§ This is a sample-by-sample (or βdotβ) multiplication) given by This is a sample-by-
sample addition given by
ο± The following function, called the π ππππ’ππ‘ function, demonstrates these operations.
12
13. Operations On Sequences (Cont.)
3. Scaling:
ο§ In this operation each sample is multiplied by a scalar Ξ±.
πΌ { π₯(π) } = { πΌπ₯(π) }
ο± An arithmetic operator (*) is used to implement the scaling operation in
MATLAB.
13
14. Operations On Sequences (Cont.)
4. Shifting:
ο§ In this operation, each sample of x(n) is shifted by an amount k to obtain a
shifted sequence y(n).
π¦(π) = { π₯(π β π) }
ο§ If we let π = π β π, then π = π + π and the above operation is given by
π¦(π + π) = { π₯ (π) }
ο± This is shown in the function π πππ βπππ‘.
14
15. Operations On Sequences (Cont.)
5. Folding:
ο§ In this operation each sample of x(n) is ο¬ipped around n = 0 to obtain a
folded sequence y(n).
π¦(π) = { π₯( β π) }
ο± In MATLAB this operation is implemented by ππππππ(π₯) function for
sample values and by βππππππ(π) function for sample positions as shown
in the π ππππππ function.
15
16. Operations On Sequences (Cont.)
6. Sample summation:
ο§ This operation diο¬ers from signal addition operation. It adds all sample
values of π₯(π) between π1 and π2.
ο± It is implemented by the π π’π(π₯(π1: π2)) function.
16
17. Operations On Sequences (Cont.)
7. Sample products:
ο§ This operation also diο¬ers from signal multiplication operation. It
multiplies all sample values of π₯(π) between π1 and π2.This operation
diο¬ers from signal addition operation. It adds all sample values of π₯(π)
between π1 and π2.
ο± It is implemented by the ππππ(π₯(π1: π2)) function.
17
18. Operations On Sequences (Cont.)
8. Signal energy:
ο§ The energy of a sequence x(n) is given by
ο± where superscript (β) denotes the operation of complex conjugation.
The energy of a ο¬nite-duration sequence π₯(π) can be computed in
MATLAB using
18
19. OPERATIONS ON SEQUENCES (Cont.)
9. Signal power:
ο§ The average power of a periodic sequence π₯(π) with fundamental period π
is given by
19
29. Even and odd synthesis
ο± A real-valued sequence x e (n) is called even (symmetric) if
π₯ π(βπ) = π₯ π(π)
ο± Similarly, a real-valued sequence x o (n) is called odd (antisymmetric) if
π₯ π(βπ) = βπ₯ π(π)
ο± Then any arbitrary real-valued sequence x(n) can be decomposed into
its even and odd components
π₯(π) = π₯ π(π) + π₯ π(π)
ο± where the even and odd parts are given by
π₯ π π =
1
2
π₯ π + π₯ βπ πππ π₯ π(π) =
1
2
[π₯(π) β π₯(βπ)]
29
30. Even and odd synthesis
ο± Using MATLAB operations discussed so far, we can obtain the following
ππ£πππππ function.
30
33. Discrete Time Systems
ο± A discrete-time system (or discrete system for short) is described as an
operator T[ Β· ] that takes a sequence x(n) (called excitation) and
transforms it into another sequence y(n) (called response). That is,
π¦(π) = π[π₯(π)]
1. LINEAR SYSTEMS:
ο§ A discrete system T[ Β· ] is a linear operator L[ Β· ] if and only if L[ Β· ]
satisο¬es the principle of superposition, namely,
πΏ π1 π₯1 π + π2 π₯2 π = π1 πΏ π₯1 π + π2 πΏ[π₯2(π)], βπ1, π2, π₯1 π , π₯1 π
33
34. Discrete Time Systems (Cont.)
2. Linear time-invariant (LTI) system:
ο§ A linear system in which an input-output pair, x(n) and y(n), is invariant to a
shift k in time is called a linear time-invariant system i.e.,
π¦(π) = πΏ[π₯(π)] β πΏ[π₯(π β π)] = π¦(π β π)
ο± For an LTI system the L[Β·] and the shifting operators are reversible as shown here.
ο± Let x(n) and y(n) be the input-output pair of an LTI system. Then the output is
given by the convolution:
π¦ π = πΏππΌ π₯ π = π₯ π β β(π) =
π=ββ
β
π₯(π)β(π β π)
34
35. Discrete Time Systems (Cont.)
3. Stability:
ο§ The primary reason for considering stability is to avoid building harmful
systems or to avoid burnout or saturation in the system operation.
ο§ A system is said to be bounded-input bounded-output (BIBO) stable if
every bounded input produces a bounded output.
| π₯(π) | < β β | π¦(π) | < β , β π₯, π¦
ο§ An LTI system is BIBO stable if and only if its impulse response is
absolutely summable.
π΅πΌπ΅π ππ‘ππππππ‘π¦ ββ
ββ
β
| β(π) | < β
35
36. Discrete Time Systems (Cont.)
4. Causality:
ο§ This important concept is necessary to make sure that systems can be
built. A system is said to be causal if the output at index π0 depends only
on the input up to and including the index π0; that is, the output does not
depend on the future values of the input.
ο§ An LTI system is causal if and only if the impulse response
β(π) = 0, π < 0
36
37. Convolution
ο± MATLAB does provide a built-in function called conv that computes the
convolution between two ο¬nite-duration sequences. The conv function
assumes that the two sequences begin at n = 0 and is invoked by
ο± Example #5:
ο§ Let the rectangular pulse π₯(π) = π’(π) β π’(π β 10) of Example 2.4 be an
input to an LTI system with impulse response β(π) = (0.9) π π’(π) .
Determine the output y(n).
ο± Solution:
37
38. Convolution (Cont.)
ο± A simple modiο¬cation of the conv function, called ππππ£_π , which
performs the convolution of arbitrary support sequences can now be
designed.
38
39. Example #6
ο± Given the following two sequences
π₯ π = 3, 11, 7, 0, β 1, 4, 2 , β 3 β€ π β€ 3;
β(π) = [2, 3, 0, β 5, 2, 1], β 1 β€ π β€ 4
determine the convolution y(n) = x(n) β h(n).
ο± Solution:
39
β
β
40. Sequence Correlations Revisited
ο± The crosscorrelation ππ₯π¦(β ) can be put in the form
ππ₯π¦(β ) = π¦(β) β π₯(ββ)
ο± The autocorrelation ππ₯π₯(β ) in the form
ππ₯π₯(β ) = π₯(β) β π₯(ββ)
ο± Therefore these correlations can be computed using the ππππ£_π
function if sequences are of ο¬nite duration.
40
41. Example #7
ο± Let π₯(π) = [3, 11, 7, π, β 1, 4, 2] be a prototype sequence, and let π¦(π)
be its noise-corrupted-and-shifted version π¦(π) = π₯(π β 2) + π€(π)
where w(n) is Gaussian sequence with mean 0 and variance 1. Compute
the crosscorrelation between y(n) and x(n).
ο± Solution:
ο§ let us compute the crosscorrelation using two diο¬erent noise sequences.
41
42. Example #7 - Solution
42
we observe that the crosscorrelation indeed peaks at β = 2, which implies that y(n) is similar to x(n) shifted by
2. This approach can be used in applications like radar signal processing in identifying and localizing targets.
43. Sequence Correlations Revisited
ο± Note that the signal-processing toolbox in MATLAB also provides a
function called xcorr for sequence correlation computations. In its
simplest form.
ο± computes the crosscorrelation between vectors x and y, while
ο± computes the autocorrelation of vector x. It generates results that are
identical to the one obtained from the proper use of the conv m
function.
ο± However, the π₯ππππ function cannot provide the timing (or lag)
information (as done by the ππππ£_π function), which then must be
obtained by some other means.
43
44. Difference Equations
ο± An LTI discrete system can also be described by a linear constant coeο¬cient
diο¬erence equation of the form
ο± If π π β 0, then the diο¬erence equation is of order π. This equation describes a
recursive approach for computing the current output, given the input values
and previously computed output values. In practice this equation is computed
forward in time, from π = ββ to π = β.
ο± Therefore another form of this equation is
44
45. Difference Equations (Cont.)
ο± A solution to this equation can be obtained in the form
π¦(π) = π¦ π»(π) + π¦ π(π)
ο± The homogeneous part of the solution, π¦ π»
(π) , is given by
π¦ π»(π) =
π=1
π
πΆ π π§ π
π
ο± where π§ π, π = 1, . . . , π are π roots (also called natural frequencies) of the
characteristic equation
0
π
π π π§ π
= 0
ο± This characteristic equation is important in determining the stability of
systems. If the roots π§ π satisfy the condition
|π§ π| < 1, π = 1, . . . , π
45
46. MATLAB Implementation
ο± A function called ππππ‘ππ is available to solve diο¬erence equations
numerically, given the input and the diο¬erence equation coeο¬cients. In
its simplest form this function is invoked by
ο± where
ο± are the coeο¬cient arrays from the difference equation, and π₯ is the
input sequence array. The output π¦ has the same length as input π₯. One
must ensure that the coeο¬cient π0 not be π§πππ.
ο± To compute and plot impulse response, MATLAB provides the function
ππππ§. When invoked by
ο± fgdg
46
47. Example #8
ο± Given the following diο¬erence equation
π¦(π) β π¦(π β 1) + 0.9π¦(π β 2) = π₯(π); β π
a. Calculate and plot the impulse response β(π) at π = β 20, . . . , 100.
b. Calculate and plot the unit step response π (π) at π = β 20, . . . , 100.
c. Is the system speciο¬ed by β(π) stable?
47
48. Example #8 - Solution
ο± From the given diο¬erence equation the coeο¬cient arrays are
ο± a. MATLAB script:
ο± b. MATLAB script:
48
49. Example #8 β Solution (Cont.)
ο± c. To determine the stability of the system, we have to determine h(n)
for all n. Although we have not described a method to solve the
diο¬erence equation,
ο§ we can use the plot of the impulse response to observe that h(n) is
practically zero for π > 120. Hence the sum |β(π)| can be determined from
MATLAB using
β’ which implies that the system is stable.
ο§ An alternate approach using MATLABβs roots function.
β’ Since the magnitudes of both roots are less than one, the system is stable.
49
50. Digital Filters
ο± Filter is a generic name that means a linear time-invariant system
designed for a speciο¬c job of frequency selection or frequency
discrimination. Hence discrete-time LTI systems are also called digital
ο¬lters. There are two types of digital ο¬lters.
ο§ FIR
ο§ IIR
50
51. FIR Digital Filters
ο± If the unit impulse response of an πΏππΌ system is of ο¬nite duration, then the
system is called a ο¬nite-duration impulse response (orππ°πΉ) ο¬lter. Hence for an
ππ°πΉ ο¬lter β(π) = 0 for π < π1 and for π > π2.
ο± The diο¬erence equation that describes a causal FIR ο¬lter is:
π¦(π) =
π=0
π
π π π₯ π β π
ο§ Furthermore, β(0) = π0 , β(1) = π1, . . . , β(π) = π π, while all other β(π)βs are 0.
ο§ FIR ο¬lters are also called Nonrecursive or moving average (MA) ο¬lters.
ο§ In MATLAB ππ°πΉ ο¬lters are represented either as impulse response values {β(π)} or as
diο¬erence equation coeο¬cients {π π} and {π0 = 1} .
ο§ Therefore to implement ππ°πΉ ο¬lters, we can use either the ππππ£(π₯, β) function (and
its modiο¬cation that we discussed) or the ππππ‘ππ(π, 1, π₯) function.
ο§ There is a diο¬erence in the outputs of these two implementations that should be
noted. The output sequence from the ππππ£(π₯, β) function has a longer length than
both the π₯(π) and β(π) sequences. On the other hand, the output sequence from the
ππππ‘ππ(π, 1, π₯) function has exactly the same length as the input π₯(π) sequence. In
practice (and especially for processing signals) the use of the filter function is
encouraged. 51
52. IIR Digital Filters
ο± If the impulse response of an LTI system is of inο¬nite duration, then the system is
called an inο¬nite-duration impulse response (or IIR) ο¬lter.
ο± The following part of the general IIR diο¬erence equation:
π=0
π
π π π¦ π β π = π₯(π)
ο§ Describe a recursive ο¬lter in which the output y(n) is recursively computed from its
previously computed values and is called an autoregressive (AR) ο¬lter. The impulse
response of such ο¬lter is of inο¬nite duration and hence it represents an IIR ο¬lter.
ο± The general IIR diο¬erence equation is:
π=0
π
π π π¦ π β π =
π=0
π
π π π₯ π β π
ο§ It has two parts: an AR part and an MA part. Such an IIR ο¬lter is called an
autoregressive moving average, or an ARMA, ο¬lter. In MATLAB, IIR ο¬lters are
described by the diο¬erence equation coeο¬cients {π π} and {π π} and are
implemented by the ππππ‘ππ(π, π, π₯) function.
52