Chapter 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 70

COURSE:

DIGITAL SIGNAL PROCESSING

Instructor: Ninh Khanh Duy


CHAPTER 2:
DISCRETE-TIME
SIGNALS & SYSTEMS

Lecture 2: Discrete-time (DT) signals


Lecture 3: Discrete-time (DT) systems
Duration: 6 periods
Lecture 2
Discrete-time (DT) Signals

! Duration: 3 periods
! Outline:
1. Representations of DT signals
2. Some elementary DT signals
3. Simple manipulations of DT signals
Sampled signals (tin hieu lay mau)
CT: contiguous-time
DT: discrete-time

Converting a CT signal into a DT signal by sampling: given xa(t) to


be a CT signal, xa(nT) is the value of xa(t) at t = nT " DT signal
xa(nT) is defined only for n an integer

x[-2] x[7]

-2T -T 0 T 2T 3T 4T 5T 6T 7T . . . nT

x a (t) = x a (nT) º x (n ), - ¥ < n < ¥


t = nT

T: sampling period (s), t: contiguous time (s), n: discrete time = sample index
Representations of DT signals

1. Functional representation

ì2 n , 1 £ n £ 3
x[n] = í
î0, elsewhere
2. Tabular representation

n … -1 0 1 2 3 4…
x[n] … 0 0 2 4 8 0…
Representations of DT signals

3. Sequence representation

{ }
x[n] = 0 , 2 , 4 , 8
­
n=0
4. Graphical representation 8
x[n]
4
2 …

-1 0 1 2 3 4 5 n
Lecture 2
Discrete-time (DT) Signals

! Duration: 3 periods
! Outline:
1. Representations of DT signals
2. Some elementary DT signals
3. Simple manipulations of DT signals
Some elementary DT signals

1. Unit step sequence


2. Unit impulse signal
3. Sinusoidal signal
4. Exponential signal
Unit step sequence

ì1, n ³ 0
u[n] = í
î0, n < 0

1 1 1 u[n]

-1 0 1 2 3 4 5 6 n
Q: x[n]=5.u[n]?
Time-shifted unit step

ì1, n ³ n 0
Replace n with n-n0 " u[n - n 0 ] = í n0: shift (an integer)
î0, n < n 0
(is a n0-samples shifted version of the signal u[n])
1 1 1
u[n-n0]

n0-1 n0 n0+1 n
Q: x[n]=-5.u[n-2]?
Unit impulse sequence

ì1, n = 0
d [ n] = í
(/delta/) î0, n ¹ 0

-2 -1 0 1 2 3 n

Q: x[n]=-5 δ[n]?
Time-shifted unit impulse

ì1, n = n 0
d[n - n 0 ] = í
î0, n ¹ n 0
1

n0-1 n0 n0+1 n

Q: x[n]=-5 δ[n+2]
Relation between unit step and unit impulse

n
u[n] = å d [
k = -¥
k ] =d[n]+d[n-1]+d[n-2]+…+d[n-M]+…
: running sum

d [n] = u[n] - u[n - 1] : first difference


x[n]d [n - n0 ] = x[n0 ]d [n - n0 ] : sample & hold
¥

å x[n]d [n - n ] = x[n ]
n = -¥
0 0
Sinusoidal signal
x (n ) = A cos(W n + q), - ¥ < n < +¥
= A cos(2pFn + q), - ¥ < n < +¥
1.5

0.5

-0.5

-1

-1.5
-20 -15 -10 -5 0 5 10 15 20
Exponential signal

x[n] = a n
1. If a is real, then x[n] is a real exponential
a > 1 " growing exponential
0 < a < 1 " shrinking exponential
-1 < a < 0 " alternate and decay
a < -1 " alternate and grows
2. If a is complex, then x[n] is a complex exponential
Exponential signal - Real examples

a>1 0<a<1

-1<a<0 a<-1
Exponential signal - Complex example
æ 1 pö
ç - + j ÷n
x[n] = 2e è 12 6 ø
j: imaginary unit
Real part
2

-1

-2
0 5 10 15 20 25 30 35 40

Imaginary part
2

-1
0 5 10 15 20 25 30 35 40
Lecture 2
Discrete-time (DT) Signals

! Duration: 3 periods
! Outline:
1. Representations of DT signals
2. Some elementary DT signals
3. Simple manipulations of DT signals
Simple manipulations of DT signals

! Transformation of time:
- Time shifting
- Time reversal
! Adding and subtracting signals
Time shifting a DT signal

x[n] " x[n - k]; k is an integer

! k > 0: right-shift x[n] by |k| samples


(delay of signal)
! k < 0: left-shift x[n] by |k| samples
(advance of signal)
Examples of time shifting

x[n]
4
2
1

-1 0 1 2 3 4 5 n

x[n+2] x[n-2]
4 4
2 2
1 1

-2 -1 0 1 2 n 0 1 2 3 4 5 n
n=-1: x[-1+2]=x[1]=1 n=4: x[4-2]=x[2]=4
Time reversal a DT signal

x[n] " x[-n]

Flip a signal x[n] about the vertical axis at n=0


Example of time reversal

x[n] 4
2
1

-1 0 1 2 3 4 5 n

4 x[-n]
2
1
n=-1: x[-(-1)]=x[1]=1

-5 -4 -3 -2 -1 0 1 n
Combining time reversal and time
shifting

x[n] " x[-n-k] (k: an interger)

Method 1: Flip first, then shift


Method 2: Shift first, then flip
Examples of combining time
reversal and time shifting

x[n] 4 x[-n+1]??
2
1 n<=-3: x[-n+1]=0
n=-2: x[-(-2)+1]=x[3]=2
n=-1: x[-(-1)+1]=x[2]=4
-1 0 1 2 3 4 5 n n=0: x[-0+1]=x[1]=1
n>=1: x[-n+1]=0
Examples of combining time
reversal and time shifting

x[n] 4
2 x[-n-1]??
1

-1 0 1 2 3 4 5 n
Adding and subtracting signals

! Do it “point by point”
! Can do using a table, or graphically, or by
computer program
! Example: x[n] = u[n] – u[n-4]

n <=-1 0 1 2 3 >=4
x[n] 0 1 1 1 1 0
Exercise

! Find x[n] = (u[n + 1] - u[n - 5])(nu[2 - n])

x[n]
2
1

-1 0 1 2 3 4 5 n

(Hint: x1[n] = u[n+1]-u[n-5], x2[n]=n.u[2-n] " x[n]=x1[n].x2[n])


Homework (HW)

Prob.1 The following graph is of signal x[n].


x[n]
Plot the following:
a) y[n]= 3x[-n-1]
b) y[n]=x[2n] - 1
c) y[n]= –x[n] + 2
n
HW

Prob.2 Sometimes signals can be decomposed into combinations of


simple unit step sequences such as this one:

Sketch y[n] and the following signals:


a) 2-3y[n]
b) 3y[n-2]
c) 2-2y[-2+n]
HW

Prob.3 Write a program to do the followings:


- Read a recorded .wav file to a data vector x & a sample
rate value Fs
- Plot the signal over time (s) and show its length in samples
and in seconds
- Playback the signal with 3 different sampling rate: Fs, Fs/2,
2*Fs & give your remarks

(Hint: read the textbook


“Applied Digital Signal Processing -Theory and Practice_Manolakis-Ingle_2011”
at pages 15, 28 & 30.)
HW
Write a program to do the followings:
Prob.4 - Given an analog sine signal x(t) having its parameters
(amplitude, frequency in Hz (denoted as F0), and phase)
- Sampling the signal with 2 dif. sampling frequencies: Fs1 =
3*F0 ("x1[n]), Fs2 = 1.5*F0 ("x2[n])
- Plot 2 resulting discrete signals x1[n] & x2[n] on the same
time axis
- Playback the 2 discrete signals with its corresponding sampling
rates : x1[n] with Fs1, x2[n] with Fs2
- Check if we can recover the original analog signal in 2 cases
(Hint: read the textbook
“Applied Digital Signal Processing -Theory and Practice_Manolakis-Ingle_2011”
at pages 15, 28 & 30.
- F0: an audible frequency in (1000Hz, 15000Hz)
- sampling x(t)=Acos(2*pi*F0*t+phi) to receive x[n]): t=n*Ts
Lecture 3
DT systems

! Duration: 3 periods
! Outline:
1. Input-output description of systems
2. DT system properties
3. Linear-time invariant (LTI) systems
Input-output description of DT systems

Think of a DT system as an operator on DT signals:

• It processes DT input signals, to produce DT output signals


• Notation: y[n] = T{x[n]}: y[n] is the response of the system T to the
excitation x[n]

• Ex1:

" a three-point moving average filter, which is often used to smooth a


signal corrupted by additive noise

• Ex2:
" a five-point median filter, used to remove spikes from experimental data
System #" Filter
Lecture 3
DT systems

! Duration: 3 periods
! Outline:
1. Input-output description of systems
2. DT system properties
3. LTI systems
DT system properties

• Causality

• Stability

• Linearity

• Time-invariance
Causality

! The output of a causal system (at each time) does not depend
on future inputs
(n0: current time instant " n0 -1: past, n0 +1: future)
" y[n0] (result) only depends on x[n0], x[n0 -1], x[n0 -2],…(cause)
for all n0 interger
" Imply if the system is physically implementable in online mode
Examples for causality

Determine which of the systems below are causal:

a) y[n] = x[-n]: Non-causal


non causal (eg. y[-1]=x[1])

b) y[n] = (n+1)x[n-1]: causal


causal since y[n0] only depends on x[n0-1]

c) y[n] = x[(n-1)2]: non causal(eg. y[0]=x[1])


Non-causal

d) y[n] = cos(w0n+x[n]): causal


causal since y[n] only depends on x[n]

e) y[n] = 0.5y[n-1] + x[n-1]: can be causal


causal since y[n] only depends on x[n-1]
Stability

! If a system “blow up” it is not stable


In particular, if a “well-behavior” signal (all values have
finite amplitude) results in infinite magnitude output, the
system is unstable
! BIBO stability: “bounded input – bounded output” –
if you put finite signals in, you will get finite signals out
Examples for stability

Determine which of the systems below are BIBO stable:

a) A unit delay system: stable

b) An accumulator: unstable

c) y[n] = cos(x[n]): stable

d) y[n] = ln(x[n]): unstable

e) y[n] =exp(x[n]): stable


Linearity

Scaling signals and adding them, then processing through the system
same as
Processing signals through system, then scaling and adding them

If T(x1[n]) = y1[n] and T(x2[n]) = y2[n]


" T(ax1[n] + bx2[n]) = ay1[n] + by2[n]

Only has theoretical meanings, but simplify modeling & analysis of real systems
Time-invariance

! If you time shift the input, get the same output, but with the
same time shift
! The behavior of the system doesn’t change with time

If T(x[n]) = y[n]
then T(x[n-n0]) = y[n-n0]

Only has theoretical meanings, but simplify modeling & analysis of real systems
Examples for linearity and time-
invariance

Prob 0. Determine if the systems below are linear and/or


time-invariant. Prove!
a) y[n] = nx[n]

Linear
Time-variant
Examples for linearity and time-
invariance

Determine if the systems below are linear and/or time-


invariant. Prove!
b) y[n ] = x 2 [n ]

Non-linear
Time-invariant
Examples for linearity and time-
invariance

Determine if the systems below are linear and/or time-


invariant. Prove!
c) M
y[n] = å br x[n - r ]
r =0
Linear
Time-invariant (LTI)
Lecture 3
DT systems

! Duration: 3 periods
! Outline:
1. Input-output description of systems
2. DT system properties
3. LTI systems
Computing the response of DT LTI
systems to arbitrary input

Method 1: based on the direct solution of the input-output equation


for the system " not often used

Method 2:

• Decompose the input signal into a sum of elementary signals


• Find the response of system
x[n] = å ck xk [n]
to each elementary signal k

• Add those responses to obtain xk [ n ] ® y k [ n]


the total response of the system x[n] ® y[n] = å ck yk [n]
to the given input signal k

" often used


Impulse representation of DT signals

¥
We can describe any DT signal x[n] as: x[n] = å x[k ]d [n - k ]
k =-¥
4
Example: x[n] 2
1

-1 0 1 2 3 n

4
1.δ[n-0] + 4.δ[n-1] + 2.δ[n-2]
2
1

-1 0 1 2 n -1 0 1 2 n -1 0 1 2 n
Impulse response of DT LTI systems

$ Any DT LTI system is characterized by its impulse response h[n].


$ Notation:

h[n]
x[n] y[n]

$ Impulse response = response of the system to the (unit) impulse

h[n]
δ[n] h[n]
h[n] = y[n] | x[n] = δ[n]
Response of LTI system to delayed impulse

h[n]
δ[n] h[n]

Time-invariant property

h[n]
δ[n-k] h[n-k]
Response of LTI system to a DT signal

δ[n-k] h[n-k]
h[n]

Time-invariant property

¥ ¥
x[n] = å x[k ]d [n - k ]
k =-¥
y[n] = å x[k ]h[n - k ]
k =-¥
h[n]

y[n] = x[n]* h[n]


Linear property Convolution sum

(an operation on 2 signals)


DT convolution formula

Convolution: an operation between the input signal to a


system and its impulse response, resulting in the output signal

x[n] y[n] = x[n]* h[n]


h[n]

In DT systems: convolution of 2 signals involves summing


the product of the 2 signals – where one of signals is flipped
and shifted ¥
y[n] = å x[k ]h[n - k ]
k =-¥
Computing the convolution sum
¥
y[n] = å x[k ]h[n - k ]
k = -¥

Suppose to compute the output y[n] at time n = n0.

1. Flip h[k] about k = 0, to obtain h[-k]

2. Shift h[-k] by n0 to the right (left) if n0 is positive (negative),


to obtain h[n0-k]

3. Multiply x[k] and h[n0-k] for all k, to obtain the product


x[k].h[n0-k]

4. Sum up the product for all k, to obtain y[n0]

Repeat from 2-4 fof all of n


The length of the convolution sum result

¥
y[n] = x[n] * h[n] = å
k =-¥
x[k ]h[n - k ]

Suppose:
Length of x[k] is Nx " N1 ≤ k ≤ N1 + Nx – 1
Length of h[n-k] is Nh " N2 ≤ n-k ≤ N2 + Nh – 1
" N1 + N2 ≤ n ≤ N1 + N2 + Nx + Nh – 2

Length of y[n]:

Ny = Nx + Nh – 1
Examples of computing the convolution sum

Ex1. Find y[n] = x[n]*h[n] where

x[n] = u[n + 1] - u[n - 3] + d [n] h[n] = 2 ( u[n] - u[n - 3])

x[n]
n
-1 0 1 2 3

h[n]
n
-1 0 1 2 3
Ex1 (cont.)

x[k] h[k] h[-k]

-1 0 1 2 3 k -1 0 1 2 3 k -2 -1 0 1 k

h[-1-k] h[1-k] h[2-k]

-4 -3 -2 -1 0 k -2 -1 0 1 2 k -1 0 1 2 k

y[n<-1] = 0; y[-1] = 2; y[0] = 6; y[1] = 8;


y[2] = 8; y[3] = 4; y[4] = 2; y[n>4] = 0
Examples of computing the convolution sum

Ex2. Find y[n] = x[n]*h[n] where x[n] = a u[n] h[n] = u[n]


n
Examples of computing the convolution sum

Ex3. Find y[n] = x[n]*h[n] where x[n] = bnu[n] and h[n] = anu[n+2]
|a| < 1, |b| < 1, a ≠ b
DT LTI properties based on
impulse response

1. Causal system: h[n] is zero for all time n<0

2. BIBO stable system:


å h[n]
n = -¥
< ¥

- Finite impulse response (FIR) systems " always stable


- Infinite impulse response (IIR) systems " can be stable or not
Examples of DT LTI properties

1. Is h[n] = 0.5nu[n] BIBO stable? Causal? Y, Y

2. Is h[n] = 3nu[n] BIBO stable? Causal? N, Y

3. Is h[n] = 3nu[-n] BIBO stable? Causal? Y, N


Convolution sum properties

! Commutative law
! Associative law
! Distributive law
Commutative law

x[n] * h[n] = h[n] * x[n]

h[n]
x[n] y[n]

x[n]
h[n] y[n]
Associative law

( x[n] * h1[n]) * h2 [n] = x[n] * (h1[n] * h2 [n])


x[n]*h1[n]
=(x[n]*h1[n])*h2[n]
h1[n] h2[n]
x[n] y[n]

=x[n]*(h1[n]*h2[n])
h1[n]*h2[n]
x[n] y[n]

h2[n] h1[n]
x[n] y[n]
Directly connected systems
Distributive law

x[n] * (h1[n] + h2 [n]) = ( x[n] * h1[n]) + ( x[n] * h2 [n])

h1[n] + h2[n]
x[n] y[n]=x[n]*(h1[n]+h2[n])

y1[n] = x[n]*h1[n]
h1[n]

x[n] y[n]

h2[n] y2[n] = x[n]*h2[n]


Parallel systems
LTI systems characterized by linear
constant coefficient difference equations

General form:

y[n] + a1 y[n - 1] + ... + a N y[n - N ] = b0 x[n] + b1 x[n - 1] + ... + bM x[n - M ]

N M
Û å a k y[n - k ] = å b r x[n - r ], a 0 = 1
k =0 r =0

N, M: non-negative integers
N: order of equation
ak, br: constant real coefficients
HW
Prob.3 Conclude about the linearity, time-invariance,
stability, causality of the following systems. Prove!

(a)

(b)

(Hint: read pp. 32-35 textbook)


Trung vị (Median) là gì?
https://vietnambiz.vn/trung-vi-median-la-gi-vi-du-ve-trung-vi-2019110713491368.htm
HW

Prob.4 Determine the causality and the BIBO stability for the
systems with the following impulse responses:
a) h[n] = sin(-n)u[n]
b) h[n] = e-nu[-n]
c) h[n] = enu[n]
d) h[n] = sin(n)u[-n]
e) h[n] = ne-nu[n]
f) h[n] = e-nsin(n)u[n]
HW

Prob.5 Find y[n] = x[n]*h[n] where:


a) x[n] = anu[n] and h[n] = u[n] – u[n-10]
b) x[n] = u[-n] and h[n] = anu[n-2], |a|<1
c) x[n] = 2δ[n+2] + 2δ[n+1] + 2δ[n-1] + 2δ[n-2] + 2δ[n-3] + 2δ[n-4]
and h[n] = δ[n] – δ[n-1] + δ[n-2]
d) x[n] = u[-n+2] and h[n] = anu[-n]
e) x[n] = 0.2nu[n] and h[n] = δ[n] – 0.2δ[n-1]
HW
Prob.6 Consider the LTI system with the input and output related by: y[n] = 0.5x[n-1] + 0.7x[n]
a) Find the impulse response h[n]
b) Is this system causal? Stable? Why?
c) Determine the system response y[n] for the input shown in Fig. (a)
d) Consider the interconnections of the LTI systems given in Fig. (b). Find the impulse
response of the total system
e) Solve for the response of the system of part (d) for the input of part (c)
HW

Denoising signal using moving averaging system:

Modify the moving_average_smoothing.m program so


that it implements the system in Prob. (3a) (slide 66,
Chapter 2) in 3 different ways:
- Averaging of time-shifted input signals
- Using conv() function
- Using filter() function

You might also like