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