EE421, Fall 1998 Michigan Technological University Timothy J. Schulz 24-Sept, 1998EE421, Lecture 51...

Preview:

Citation preview

24-Sept, 1998 EE421, Lecture 5 1

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Lecture 5: Block Processing for FIR Filters

Block processing methods– recorded data: x = {x0 x1 x2 … xL-1}

• length: Lx = L

– system impulse response: h = {h0 h1 h2 h3 … hM}

• length: Lh = M+1

– output data: y = {y0 y1 y2 y3 … yLy-1}

• length: Ly = Lx + Lh - 1

– key question: how do we process h and x to compute y?

x h y

24-Sept, 1998 EE421, Lecture 5 2

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Convolution table

y(0) = h(0)x(0)y(1) = h(0)x(1) + h(1)x(0)y(2) = h(0)x(2) + h(1)x(1) + h(2)x(0)y(3) = h(0)x(3) + h(1)x(2) + h(2)x(1) + h(3)x(0)y(4) = h(0)x(4) + h(1)x(3) + h(2)x(2) + h(3)x(1) + h(4)x(0)

nji

ji

m

jxih

mnxmhny

,)()(

)()()(

x(0) x(1) x(2) x(3) x(4)

h(0) h(0)x(0) h(0)x(1) h(0)x(2) h(0)x(3) h(0)x(4)

h(1) h(1)x(0) h(1)x(1) h(1)x(2) h(1)x(3) h(1)x(4)

h(2) h(2)x(0) h(2)x(1) h(2)x(2) h(2)x(3) h(2)x(4)

h(3) h(3)x(0) h(3)x(1) h(3)x(2) h(3)x(3) h(3)x(4)

h(4) h(4)x(0) h(4)x(1) h(4)x(2) h(4)x(3) h(4)x(4)

y(0)

y(1)

y(2)

y(3)

y(4)

24-Sept, 1998 EE421, Lecture 5 3

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Convolution table– example: x = {1 2 1 3}, h = {4 2 1}

n=0 n=0

h\ x 1 2 1 3

4 4 8 4 12

2 2 4 2 6

1 1 2 1 3y(0) = 4

y(1) = 10

y(2) = 9 y(3) = 16 y(4) = 7 y(5) = 3

y = {4 10 9 16 7 3}

n=0

24-Sept, 1998 EE421, Lecture 5 4

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

LTI Form

y(n) = … + x(0)h(n) + x(1)h(n-1) + x(2)h(n-2) + x(3)h(n-3) + …

m

mnhmxny )()()(

h(0) h(1) h(2) h(3) h(4)

x(0) x(0)h(0) x(0)h(1) x(0)h(2) x(0)h(3) x(0)h(4)

x(1) x(1)h(- 1) x(1)h(0) x(1)h(1) x(1)h(2) x(1)h(3)

x(2) x(2)h(- 2) x(2)h(- 1) x(2)h(0) x(2)h(1) x(2)h(2)

x(3) x(3)h(- 3) x(3)h(- 2) x(3)h(- 1) x(3)h(0) x(3)h(1)

x(4) x(4)h(- 4) x(4)h(- 3) x(4)h(- 2) x(4)h(- 1) x(4)h(0)

y(0) y(1) y(2) y(3) y(4)

24-Sept, 1998 EE421, Lecture 5 5

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

LTI form– example: x = {1 2 1 3}, h = {4 2 1}

n=0 n=0

x\ h 4 2 1 0 0 0 0

1 4 2 1 0 0 0 0

2 0 8 4 2 0 0 0

1 0 0 4 2 1 0 0

3 0 0 0 12 6 3 0

4 10 9 16 7 3 0

y = {4 10 9 16 7 3}

n=0

24-Sept, 1998 EE421, Lecture 5 6

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Matrix form:Hxy

)(

)(

)(

)(

)()()()(

)()()()(

)()()()(

)()()()(

)()()()(

)()()()(

)(

)(

)(

)(

)(

)(

3x

2x

1x

0x

2h3h4h5h

1h2h3h4h

0h1h2h3h

1h0h1h2h

2h1h0h1h

3h2h1h0h

5y

4y

3y

2y

1y

0y

24-Sept, 1998 EE421, Lecture 5 7

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Matrix form– example: x = {1 2 1 3}, h = {4 2 1}

n=0n=0

3

1

2

1

1000

2100

4210

0421

0042

0004

3

7

16

9

10

4

y = {4 10 9 16 7 3}

n=0

24-Sept, 1998 EE421, Lecture 5 8

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Flip-and-slide form:

y(n) = h(0)x(n) + h(1)x(n-1) + h(2)x(n-2) + … + h(L)x(n-L)

0 0 0 x(0) x(1) x(2) x(3) x(4) 0 0 0

m

mnxmhny )()()(

h(2) h(1) h(0)

y(0)

h(2) h(1) h(0)

y(1) y(2)

h(2) h(1) h(0)h(2) h(1) h(0)

y(3)

h(2) h(1) h(0)

y(4)

h(2) h(1) h(0)

y(5)

24-Sept, 1998 EE421, Lecture 5 9

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Flip-and-slide form:– example: x = {1 2 1 3}, h = {4 2 1}

n=0 n=0

0 0 0 1 2 1 3 0 0 0

1 2 4

4

1 2 4

10 9

1 2 4 1 2 4

16

1 2 4

7

1 2 4

3

y = {4 10 9 16 7 3}

n=0

24-Sept, 1998 EE421, Lecture 5 10

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Programming considerations– convolution table form

function y = conv(h, x)

Lh = length(h);Lx = length(x);Ly = Lh+Lx-1;y = zeros(1,Ly);for n = 0:Ly-1 y(n+1) = 0; for i = 0:Lh-1 for j = 0:Lx-1 if (i+j == n) y(n+1) = y(n+1) + h(i+1)*x(j+1); end; end endend

All these for loops willbe inefficient in Matlab!

24-Sept, 1998 EE421, Lecture 5 11

EE421, Fall 1998Michigan Technological University

Timothy J. Schulz

Block Processing

Programming considerations– LTI form

function y = conv(h, x)Lh = length(h);Lx = length(x);Ly = Lh+Lx-1; y = zeros(1,Ly); for j = 0:Lx-1 shifth = [zeros(1, j) h zeros(1,Ly-Lh-j)]; y = y + x(j+1)*shifth;end

Only 1 for loop!