polytechnic university - department of electrical...

45
EE3054 Signals and Systems Lecture 1 FIR Filtering Introduction Yao Wang Polytechnic University Most of the slides included are extracted from lecture presentations prepared by McClellan and Schafer

Upload: others

Post on 12-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

EE3054 Signals and Systems

Lecture 1FIR Filtering Introduction

Yao WangPolytechnic University

Most of the slides included are extracted from lecture presentations prepared by McClellan and Schafer

Page 2: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 2

License Info for SPFirst Slides

� This work released under a Creative Commons Licensewith the following terms:

� Attribution� The licensor permits others to copy, distribute, display, and perform

the work. In return, licensees must give the original authors credit.

� Non-Commercial� The licensor permits others to copy, distribute, display, and perform

the work. In return, licensees may not use the work for commercial purposes—unless they get the licensor's permission.

� Share Alike� The licensor permits others to distribute derivative works only under

a license identical to the one that governs the licensor's work.� Full Text of the License� This (hidden) page should be kept with the presentation

Page 3: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

What is a signal?

� Speech waveform in time (1-D signal)� Stock prices in time (1-D signal)� Images (2-D signal)� We will focus on 1-D signal in this class� Continuous time signal x(t) � Discrete time signal x[n]

� Discrete in nature� Sampled from continuous time signal

Page 4: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 4

A Speech Signal:

Page 5: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

What is a system?

� Something that transforms an input signal to another signal� Speech: Noise removal, echo cancellation, …� Image: contrast enhancement, deblurring, …

� General mathematical description:� y(t) = T ( x(t) )� y[n] = T ( x[n] )

� EXAMPLES:� POINTWISE OPERATORS

� SQUARING: y[n] = (x[n])2

� RUNNING AVERAGE� RULE: “the output at time n is the average of three consecutive

input values”

Page 6: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

How to characterize signals?

� In time domain directly� In a transform domain:

� Represent a signal as sum of some basis signals � Coefficients for different bases leads to a transform

domain representation� Fourier transform:

� Use sinusoidal signals as bases� for both continuous and discrete time

� Z-transform: for discrete time only� Laplace transform: for continuous time only

Page 7: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

How to characterize systems?

� Impulse response � Frequency response � Helpful to look from a transformed domain

representation� Fourier transform:

� Impulse response -> frequency response� Z-transform/Laplace transform:

� impulse response -> transfer function

Page 8: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

Topics Covered in This Course

� Discrete time signals and systems� Linear time invariant systems � Convolution or filtering� Impulse response� Frequency response� Z-transform analysis� Discrete time Fourier transform

� Continuous time signals and systems� Sampling of continuous time signals� Using MATLAB for implementing signal and system

operations and transforms

Page 9: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 9

LECTURE OBJECTIVES

� INTRODUCE FILTERING IDEA� Weighted Average� Running Average

� FINITE IMPULSE RESPONSE FILTERS�� FIRFIR Filters� Show how to compute the output y[n] from

the input signal, x[n]

Page 10: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 10

DIGITAL FILTERING

� CONCENTRATE on the COMPUTER� PROCESSING ALGORITHMS� SOFTWARE (MATLAB)� HARDWARE: DSP chips, VLSI

� DSP: DIGITAL SIGNAL PROCESSING

COMPUTER D-to-AA-to-Dx(t) y(t)y[n]x[n]

Page 11: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 11

DISCRETE-TIME SYSTEM

� OPERATE on x[n] to get y[n]� WANT a GENERAL CLASS of SYSTEMS

� ANALYZE the SYSTEM� TOOLS: TIME-DOMAIN & FREQUENCY-

DOMAIN� SYNTHESIZE the SYSTEM

COMPUTERy[n]x[n]

Page 12: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 12

D-T SYSTEM EXAMPLES

� EXAMPLES:� POINTWISE OPERATORS

� SQUARING: y[n] = (x[n])2

� RUNNING AVERAGE� RULE: “the output at time n is the average of three

consecutive input values”

SYSTEMy[n]x[n]

Page 13: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 13

DISCRETE-TIME SIGNAL

� x[n] is a LIST of NUMBERS� INDEXED by “n”

STEM PLOT

Page 14: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 14

3-PT AVERAGE SYSTEM� ADD 3 CONSECUTIVE NUMBERS

� Do this for each “n”Make a TABLE

n=0

n=1

])2[]1[][(][ 31 ++++= nxnxnxny

Page 15: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 15

INPUT SIGNAL

OUTPUT SIGNAL

])2[]1[][(][ 31 ++++= nxnxnxny

Page 16: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 16

ANOTHER 3-pt AVERAGER

� Uses “PAST” VALUES of x[n]� IMPORTANT IF “n” represents REAL TIME

� WHEN x[n] & y[n] ARE STREAMS

])2[]1[][(][ 31 −+−+= nxnxnxny

Page 17: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

ANOTHER 3-pt AVERAGER

� The output signals in previous examples are shifted from the input signals

� To align the output with the input, use both “PAST” and “FUTURE” VALUES of x[n]

� Go through on the board

])1[][]1[(][ 31 +++−= nxnxnxny

Page 18: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 18

PAST, PRESENT, FUTURE

“n” is TIME

Page 19: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 19

3-pt AVG EXAMPLE

USE PAST VALUES

400for)4/8/2cos()02.1(][ :Input ≤≤++= nnnx n ππ

Page 20: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 20

7-pt AVG EXAMPLE

CAUSAL: Use Previous

LONGER OUTPUT

400for)4/8/2cos()02.1(][ :Input ≤≤++= nnnx n ππ

Page 21: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 21

FILTERED STOCK SIGNAL

OUTPUT

INPUT

50-pt Averager

Page 22: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 22

GENERAL FIR FILTER

� FILTER COEFFICIENTS {bk}� DEFINE THE FILTER

� For example,

∑=

−=M

kk knxbny

0][][

]3[]2[2]1[][3

][][3

0

−+−+−−=

−=∑=

nxnxnxnx

knxbnyk

k

}1,2,1,3{ −=kb

Page 23: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 23

Example

� Given an input signal� Compute the output of the previous filter

Page 24: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 24

GENERAL FIR FILTER

� FILTER COEFFICIENTS {bk}

� FILTER ORDER is M� FILTER LENGTH is L = M+1

� NUMBER of FILTER COEFFS is L

∑=

−=M

kk knxbny

0][][

Page 25: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 25

GENERAL FIR FILTER

� SLIDE a WINDOW across x[n]

x[n]x[n-M]

∑=

−=M

kk knxbny

0][][

Page 26: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

More on signal ranges and lengths after filtering

� Input signal from 0 to N-1, length=L1=N� Filter from 0 to M, length = L2= M+1� Output signal?

� From 0 to N+M-1, length L3=N+M=L1+L2-1

Page 27: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

Causal vs. Non-causal Filters?

� So far we only considered the filters that range from 0 to M

� Output at n depends on input from n-M to n (past values only)

� These are called “Causal” filters� More generally, the filter may range from M1 to

M2� Output at n depends on input from n-M2 to n-M1� Ex. Centered averaging over 7 points, M1=-3,

M2=3

Page 28: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 28

==

00

01][

n

nnδ

Unit Impulse Signal

� x[n] has only one NON-ZERO VALUE

1

n

UNIT-IMPULSE

Page 29: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 29

UNIT IMPULSE SIGNAL δδδδ[n]

δδδδ[n] is NON-ZEROWhen its argumentis equal to ZERO

]3[ −nδ 3=n

Page 30: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 30

]4[2]3[4]2[6]1[4][2][ −+−+−+−+= nnnnnnx δδδδδ

Any x[n] Can be Represented by Impuse Signals!

� Use SHIFTED IMPULSES to write x[n]

Page 31: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 31

SUM of SHIFTED IMPULSES

This formula ALWAYS works

Page 32: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 32

4-pt AVERAGER

� CAUSAL SYSTEM: USE PAST VALUES])3[]2[]1[][(][ 4

1 −+−+−+= nxnxnxnxny

� INPUT = UNIT IMPULSE SIGNAL = δδδδ[n]

]3[]2[]1[][][][][

41

41

41

41 −+−+−+=

=nnnnny

nnxδδδδ

δ

� OUTPUT is called “IMPULSE RESPONSE”},0,0,,,,,0,0,{][ 4

141

41

41

��=nh

Page 33: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 33

},0,0,,,,,0,0,{][ 41

41

41

41

��=nh

4-pt Avg Impulse Response

δδδδ[n] “READS OUT” the FILTER COEFFICIENTS

n=0“h” in h[n] denotes Impulse Response

1

n

n=0n=1

n=4n=5

n=–1

NON-ZERO When window overlaps δδδδ[n]

])3[]2[]1[][(][ 41 −+−+−+= nxnxnxnxny

Page 34: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 34

What is Impulse Response?

� Impulse response is the output signal when the input is an impulse

� Finite Impulse Response (FIR) system:� Systems for which the impulse response has finite

duration� For FIR system, impulse response = Filter

coefficients� h[k] = b_k� Output = h[k]* input

Page 35: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 35

FIR IMPULSE RESPONSE

� Convolution = Filter Definition� Filter Coeffs = Impulse Response

∑=

−=M

kknxkhny

0][][][

CONVOLUTION

∑=

−=M

kk knxbny

0][][

Page 36: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 36

]4[]3[]2[2]1[][][ −+−−−+−−= nnnnnnh δδδδδ

MATH FORMULA for h[n]

� Use SHIFTED IMPULSES to write h[n]

1

n

–1

2

0 4

][nh

}1,1,2,1,1{ −−=kb

Page 37: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 37

∑=

−=M

kknxkhny

0][][][

Convolution Sum

�� Output = Convolution of x[n] & h[n]Output = Convolution of x[n] & h[n]� NOTATION:� Here is the FIR case:

FINITE LIMITS

FINITE LIMITSSame as bk

][][][ nxnhny ∗=

Page 38: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 38

CONVOLUTION Example

n −1 0 1 2 3 4 5 6 7x[n] 0 1 1 1 1 1 1 1 ...h[n] 0 1 −1 2 −1 1 0 0 0

0 1 1 1 1 1 1 1 10 0 −1 −1 −1 −1 −1 −1 −10 0 0 2 2 2 2 2 20 0 0 0 −1 −1 −1 −1 −10 0 0 0 0 1 1 1 1

y[n] 0 1 0 2 1 2 2 2 ...

][][]4[]3[]2[2]1[][][

nunxnnnnnnh

=−+−−−+−−= δδδδδ

]4[]4[]3[]3[]2[]2[

]1[]1[][]0[

−−−−

nxhnxhnxhnxhnxh

Page 39: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 39

Convolution via Synthetic Polynomial Multiplication

� Another example

Page 40: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 40

GENERAL FIR FILTER� SLIDE a Length-L WINDOW over x[n]� When h[n] is not symmetric, needs to flip h(n) first!

x[n]x[n-M]

Page 41: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 41

DCONVDEMO: MATLAB GUI

Page 42: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 42

� Go through the demo program for different types of signals

Page 43: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 43

� Length of filtered signals� Alignment of input and output

Page 44: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

1/22/2008 © 2003, JH McClellan & RW Schafer 44

]1[][][ −−= nununy

POP QUIZ

� FIR Filter is “FIRST DIFFERENCE”� y[n] = x[n] - x[n-1]

� INPUT is “UNIT STEP”

� Find y[n]

<

≥=

00

01][

n

nnu

][]1[][][ nnununy δ=−−=

Page 45: Polytechnic University - Department of Electrical ...eeweb.poly.edu/~yao/EE3054/Intro_Ch5.1-5.3_L1.pdfPolytechnic University ... Represent a signal as sum of some basis signals Coefficients

READING ASSIGNMENTS

� This Lecture:� Chapter 1� Chapter 5, Sects. 5-1, 5-2 and 5-3 (partial)