Ece2610 Chap6
Ece2610 Chap6
of FIR Filters
Chapter
0n
j
n .
x n = Ae e
n ,
(6.1)
bk x n k
k=0
bk Ae
0 n k
j j
(6.2)
k=0
61
0n M
j j
y n = Ae e
0n
j j
= Ae e
bk e
k = 0
He
0
j
0 k
j
(6.3)
He =
bk e
k
j
(6.4)
k=0
+ j sin
, where sine and cosine are
Note: e j = cos
62
that is
The frequency response is a complex function of
generally viewed in either polar or rectangular form
He = He e
j H e
(6.5)
= Re H e + jIm H e
yn = He e
j H e
= H e Ae
n
j j
Ae e
(6.6)
n
j H e + j
Example: b k = 1 1 3 1 1
The frequency response of this FIR filter is
He =
bk e
k
j
k=0
= 1+e
+ 3e
j 2
+e
j 3
+e
j 4
63
He = e
= e
j2
j2
j2
+ 2 cos
+ 3
2 cos 2
+e
+3+e
+e
j2
j
+ 2 cos 2
H e = 3 + 2 cos
H e = 2
Why?
w = 0:2*pi/200:2*pi;
H = exp(-j*2*w).*(3 + 2*cos(w) + 2*cos(2*w));
subplot(211)
plot(w,abs(H))
axis([0 2*pi 0 8])
grid
ylabel('Magnitude')
subplot(212)
plot(w,angle(H))
axis([0 2*pi -pi pi])
grid
ylabel('Phase (rad)')
64
Magnitude
8
6
4
3.248
2
0
6 2
6 2
Phase (rad)
2
0
2
-2
0
3
hat() (rad)
j1 n
j2
j 1 2
5e
j1 n
jn
0 = 1 is H e j1 =
The amplitude response or gain at
3.248; why?
65
(6.7)
(6.8)
n + A
0n +
A
j
j
j
j
y n = --- H e 0 e 0
+ --- H e 0 e
2
2
(6.9)
= H*e
(6.10)
= Re H e jIm H e
= H e H e
66
= A He
0
j
0 n + + H e j
j
0 n + + H e j
j
+e
e
------------------------------------------------------------------------------------------------2
yn = A He
0
j
(6.11)
0 n + + H e j 0
cos
We see that when a real sinusoid passes through an LTI system, such as an FIR filter (having real coefficients), the output is also a real sinusoid which has picked up the magnitude
=
x n = X0 +
k n + X ,
X k cos
k
(6.12)
k=1
y n = X0 H e
N
Xk H e
k
j
k n + X + H e j k
cos
k
(6.13)
k=1
67
x n = 10 + 4 cos --- n +
--- + 3 cos --- n ---
3
4
4
8
The frequency response is
He = 1 e
= e
+e
j2
1 + 2 cos
k = 0 4 3
The input frequencies are
j0
He = e
j0
1 + 2 cos 0 = 1
He
j 4
= e
j 4
1 + 2 cos 4 = 0.4142e
He
j 3
= e
j 3
1 + 2 cos 3 = 0
j 4
Thus
w = 0:pi/200:pi;
H = 1 - exp(-j*w) + exp(-j*2*w);
subplot(211)
plot(w,abs(H))
grid
hold
plot([pi/4 pi/4],[0 3],'r')
68
>>
>>
>>
>>
>>
>>
>>
>>
>>
j
He
Magnitude
2.5
2
0.4142
1.5
1
0.5
0
0.5
--4
--3
1.5
2.5
3.5
1.5
2.5
3.5
Phase (rad)
--4
1
0
1
2
0.5
Digital Frequency
69
n
j
un
(6.14)
and
1, n 0
un
0, otherwise
(6.15)
b k Xe
n k
j
un k
(6.16)
k=0
hk
un k
...
n
610
yn =
n0
0,
bk e
k
j
Xe
k=0
n
j
, 0nM
(6.17)
M
k
n
j
j
Xe
b
e
, nM
k
k = 0
y n = H e Xe n M
(6.18)
611
>> n = -5:20;
>> x = (10 + 4*cos(pi/4*n+pi/8) + ...
3*cos(pi/3*n-pi/4)).*ustep(n,0);
>> y = filter([1 -1 1],1,x);
>> subplot(211)
>> stem(n,x,'filled')
>> grid
>> ylabel('x[n]')
>> subplot(212)
>> stem(n,y,'filled')
>> hold
Current plot released
>> stem(n,y,'filled')
>> grid
>> ylabel('y[n]')
>> xlabel('Sample Index n')
20
x[n]
15
10
0
5
10
15
20
10
15
20
Transient
Interval
20
15
y[n]
10
5
0
5
5
Steady-state
0
5
Sample Index n
612
2 1.6568 = 3.3138
11.5
11
y[n]
10.5
DC = 10
10
y[n] peak
lag 1/2
sample =
/8
9.5
8.5
10
15
20
Sample Index n
613
hn =
h k n k H e =
k=0
h k e
k
j
k=0
Example: h n H e
Given say
h n = 2 n + 3 n 1 2 n 2
we immediately see that b k = 2 3 2
The difference equation is
y n = 2x n + 3x n 1 2x n 2
The frequency response is
H e = 2 + 3e
2e
j 2
614
Suppose that
H e = 1 + 4e
j 2
+ 4e
j 4
H e = 1 + 8e
= 1 + 8e
e
j2
j2
j2
+ e -
---------------------------
j2
cos 2
2 e j 2
Example: H e j = 2j sin
H e = 2je
2 e
j
= 1e
2
j
2
j
e
----------------------------------
2j
615
Periodicity of H e j
+ 2
j
He
(6.19)
+ 2
j
bk e
+ 2
j
k=0
bk e
k=0
j2
= He
(6.20)
This result is consistent with the fact that sinusoidal signals
are insensitive to 2 frequency shifts, i.e.,
x n = Xe
+ 2 n
j
= Xe
n j2n
j
= Xe
n
j
616
= H * e
(6.21)
proof
M
k *
j
*
bk e
H e =
=
k = 0
bk e
k
j
b *k e
k
j
k=0
= He
(6.22)
k=0
H e
= He
= H e
(6.23)
Im H e
= Re H e
(6.24)
= Im H e
617
618
He = e
Magnitude Response
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
n0
j
n0
= 1
n0 = 4
0.5
0.5
1.5
2.5
2.5
Linear Phase
2
0
MATLAB
wraps the
phase mod2
0.5
1.5
hat()
619
He = 1 e
+ j sin
= 1 cos
w = -pi:pi/100:pi;
H = freqz([1 -1],1,w); %use a custom w axis
subplot(211)
plot(w,abs(H))
axis([-pi pi 0 2]); grid; ylabel('Magniude Response')
subplot(212)
plot(w,angle(H))
axis([-pi pi -2 2]); grid;
ylabel('Phase Response (rad)')
xlabel('hat(\omega)')
Magnitude Response
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
2
2 sin
1.5
1
0.5
0
0
hat()
2
1
sin
atan ----------------------
1 cos
0
1
2
620
H e = 1 + 2e
+e
j2
= e
2 + 2 cos
w = -pi:pi/100:pi;
H = freqz([1 2 1],1,w);
subplot(211)
plot(w,abs(H))
axis([-pi pi 0 4]); grid;
ylabel('Magnitude Response')
subplot(212)
plot(w,angle(H))
axis([-pi pi -pi pi]); grid;
ylabel('Phase Response (rad)')
xlabel('hat(\omega)')
Magnitude Response
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
4
3
2 + 2 cos
2
1
0
0
hat()
0
2
3
621
n
j
(6.25)
is
With LTI #1 followed by LTI #2, the output at frequency
y 1 n = H 2 e H 1 e e
= H 2 e H 1 e e
n
j
n
j
(6.26)
622
is
With LTI #2 followed by LTI #1, the output at frequency
y 2 n = H 1 e H 2 e e
= H 1 e H 2 e e
n
j
(6.27)
n
j
H cascade e = H e = H 1 e H 2 e
(6.28)
h n = h 1 n * h 2 n H 1 e H 2 e = H e
(6.29)
H1 e = 1 + e
H 2 e = 1 + 2e
+e
j2
He = 1 + e
= 1 + 3e
ECE 2610 Signals and Systems
1 + 2e
+ 3e
j2
+e
+e
j2
j3
623
L1
xn k
(6.30)
k=0
(6.31)
k=0
624
k
=
k=0
L1
1------------- , 1
1
L,
= 1 (why?)
(6.32)
1 e j L
1
H e = --- ----------------------
L
j
1e
e j L 2 e j L 2 e j L 2
1
= --- ----------------------------------------------------------------
L j 2 j 2 j 2
e
e
e
(6.33)
L 2 j L 1 2
sin
= --------------------------- e
L sin
2
Notice that the phase response is composed of a linear term
L 1 2
j
L 2 /
and due to the sign changes of sin
e
2
L sin
In MATLAB
L 2
j
sin
L = -------------------------D L e = diric
2
L sin
625
Magnitude Response
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
L = 10
2
= ----
L
0.5
--5
1 2
-----5
j4.5
3
------ 2
5
4
-----5
on this segment
0
2
3
0
hat()
626
Suppose that
x t = Xe
jt
(6.34)
jnT s
= Xe
n
j
(6.35)
f
= ----- =
s
Ts
(6.36)
----f = ------------ = - f s
2
2T s
As long as the input analog frequency satisfies the sampling
theorem, i.e., T s or f f s 2 , the output of the discrete-time system will be
ECE 2610 Signals and Systems
627
y n = H e Xe
n
j
(6.37)
jT s
Xe
jT s n
(6.38)
jT s
Xe
j2f f s
jt
Xe
j 2f f s t
(6.39)
628
plot(w,abs(H))
axis([-pi pi 0 1]); grid
ylabel('Magnitude Response')
subplot(212)
plot(w,angle(H))
axis([-pi pi -pi pi]); grid
ylabel('Phase Response (rad)')
xlabel('hat(\omega)')
Magnitude Response
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
j
Magnitude and Phase Plots of H e
0.5
0
hat()
2
0
2
subplot(211)
plot(w*1000/(2*pi),abs(H))
grid
ylabel('Magnitude Response')
subplot(212)
plot(w*1000/(2*pi),angle(H))
grid
ylabel('Phase Response (rad)')
xlabel('f (Hz)')
629
Magnitude Response
j2f f s
0.5
0
500
400
300
200
100
100
200
300
400
500
400
300
200
100
0
f (Hz)
100
200
300
400
500
4
2
0
2
4
500
(6.40)
630
5 sin 2
(6.41)
He
0.2472e
j0.2
>> diric(0.2*pi,5)
ans = 0.6472
>> diric(0.6*pi,5)
ans = -0.2472 % also = 0.2472 at angle +/- pi
(6.43)
(6.44)
631
Interpretation of Delay
In the study of the moving average filter, it was noted that
H e = D L e e
L 1 2
j
He = e
jn 0
H e = H 1 e H 2 e
The L-point moving average filter thus incorporates a delay
of L 1 2 samples
Viewed as a cascade of subsystems
H e = DL e e
L 1 2
j
(6.45)
632