You are on page 1of 64

Chapter 10

10.1 To compute the filter orders, we use Kaisers formula of Eq. (10.3), Bellangers formula
of Eq. (10.4), and Hermanns formula of Eq. (10.5).

Filter #1:
Kaisers formula -
( )
( )
158 097 . 157
2 / 10625 . 0 14375 . 0 6 . 14
13 00012 . 0 0224 . 0 log 20
10
=

=

N
Bellangers formula -
( )
( )
163 575 . 162 1
2 / 10625 . 0 14375 . 0 3
000112 . 0 0224 . 0 10 log 2
10
=

=

N
Hermanns formula -
( ) ( ) ( ) [ ]
( ) ( ) [ ] 8326 . 2 4278 . 0 0224 . 0 log 5941 . 0 0224 . 0 log 00266 . 0
000112 . 0 log 4761 . 0 0224 . 0 log 07114 . 0 0224 . 0 log 005309 . 0 ,
10
2
10
10 10
2
10
= + +
+ =
s p
D
( ) [ ] 1913 . 12 000112 . 0 log 0224 . 0 log 51244 . 0 01217 . 11 ,
10 10
= + =
s p
F
( ) [ ]
( )
151 8434 . 150
2 / 10625 . 0 14375 . 0
2 / 10625 . 0 14375 . 0 1913 . 12 8326 . 2
2
=

=

N

Filter #2:
Kaisers formula -
( )
( )
34 186 . 33
2 / 2075 . 0 2875 . 0 6 . 14
13 034 . 0 017 . 0 log 20
10
=

=

N
Bellangers formula -
( )
( )
37 3012 . 36 1
2 / 2075 . 0 2875 . 0 3
034 . 0 017 . 0 10 log 2
10
=

=

N
Hermanns formula -
( ) ( ) ( ) [ ]
( ) ( ) [ ] 474777 . 1 4278 . 0 017 . 0 log 5941 . 0 017 . 0 log 00266 . 0
034 . 0 log 4761 . 0 017 . 0 log 07114 . 0 017 . 0 log 005309 . 0 ,
10
2
10
10 10
2
10
= + +
+ =
s p
D
( ) [ ] 85791019 . 10 034 . 0 log 017 . 0 log 51244 . 0 01217 . 11 ,
10 10
= + =
s p
F
( ) [ ]
( )
37 435 . 36
2 / 2075 . 0 2875 . 0
2 / 2075 . 0 2875 . 0 85791019 . 10 474777 . 1
2
=

=

N

Filter #3:
Kaisers formula -
( )
( )
12 6107 . 11
2 / 345 . 0 575 . 0 6 . 14
13 0137 . 0 0411 . 0 log 20
10
=

=

k
N
Bellangers formula -
( )
( )
13 04 . 12 1
2 / 345 . 0 575 . 0 3
0137 . 0 0411 . 0 10 log 2
10
=

=

N
Hermanns formula -
Not for sale 324
( ) ( ) ( ) [ ]
( ) ( ) [ ] 4424 . 1 4278 . 0 0411 . 0 log 5941 . 0 0411 . 0 log 00266 . 0
0137 . 0 log 4761 . 0 0411 . 0 log 07114 . 0 0411 . 0 log 005309 . 0 ,
10
2
10
10 10
2
10
= + +
+ =
s p
D
( ) [ ] 256666 . 11 0137 . 0 log 0411 . 0 log 51244 . 0 01217 . 11 ,
10 10
= + =
s p
F
( ) [ ]
( )
12 248 . 11
2 / 345 . 0 575 . 0
2 / 345 . 0 575 . 0 256666 . 11 4424 . 1
2
=

=

N

10.2 and 75 = N 05 . 0 =
p s
and we assume .
p s
=
(a) Using Kaisers formula of Eq. (10.3):
[ ]
375 . 40 009577 . 0 10
20
13 2 / 05 . 0 6 . 14 75
= = =

+
s s

dB.
(b) Using Bellangers formula of Eq. (10.4):
5 . 38 0119 . 0 10 1 . 0
2 / 1
2
2 / 05 . 0 3 76
= =

s s

dB.
(c) Using Hermanns formula of Eq. (10.5):
( ) ( ) ( ) [ ]
2
1 1
2 / 2 /
p s p s s
b N D b F + = =

( ) ( ) ( ) [ ]( )
( ) ( ) [ ]
( ) ( ) ( ) ( )
( ) ( )
( ) ( ) ( )( ) ( )( )
6 10 5 3
2
10 4 2
3
10 1
6 10 5
2
10 4
10 3
2
10 2
3
10 1
6 10 5
2
10 4
10 3 10 2
2
10 1
log log log
log log
log log log
log log
log log log
a a a a a a D
a a a
a a a D
a a a
a a a D
s s s s
s s
s s s s
s s
s s s s
+ + =

+ + =
+ +
+ + =

Let (
s
x )
10
log = , and thus
( ) 875697 . 1 4278 . 0 0702 . 1 06848 . 0 005309 . 0
2 3
= + =

x x x D
s

Solving for x gives us three possible solutions:
4263 . 10 , 94654 . 1 , 3787 . 21 = = = x x x
The most reasonable solution is the second. Therefore,
93 . 38 0113 . 0 = =
s s

10.3 and 75 = N = = 05 . 0
p s

( ) 9 . 34 8 285 . 2 = + = N
s
dB.

10.4 The ideal L -band digital filter ) (z H
ML
has a frequency response given by
for , ) (
k
j
ML
A e H =

,
1 k k

, 1 L k and can be considered as sum of L ideal

bandpass filters with cutoff frequencies at and where
and Now from Eq. (10.47) the impulse response of an ideal bandpass filter is
1
1

=
k
k
c
,
2
k
k
c
= 0
0
1
=
c

.
2
=
L
c

Not for sale 325

given by
.
) sin( ) sin(
] [
1 2
n
n
n
n
n h
c c
BP

=
Therefore ,
n
n
n
n
n h
k k k
BP

) sin( ) sin(
] [
1
= . Hence,

=

= =
L
k
k k
k
L
k
k
BP ML
n
n
n
n
A n h n h
1
1
1
) sin( ) sin(
] [ ] [

=
1
2
1
1
2
1
1
) sin( ) sin( ) sin( ) 0 sin( ) sin(
L
k
k k
k
L
k
k
k
n
n
n
n
A
n
n
A
n
n
n
n
A

+

n
n
n
n
A
L L
L

) sin( ) sin(
1

n
n
A
n
n
A
n
n
A
n
n
A
L
L
L
k
L
k
k
k
k
k

) sin( ) sin( ) sin( ) sin(

1
1
2
1
2
1 1
1

+ =

.
) sin( ) sin(
1
1 2
1

= =

=
L
k
L
k
k
k
k
k
n
n
A
n
n
A

Since , =
L
. 0 ) sin( = n
L
n
n
A
L
L

) sin(
to the first sum in the above
expression and change the index range of the second sum, resulting in

.
) sin( ) sin(
] [
1
1
1
1
=

=
+
=
L
k
L
k
k
k
k
k ML
n
n
A
n
n
A n h

Finally, since , 0
1
=
+ L
A we can add a term
n
n
A
L
L

) sin(
1 + to the second sum. This leads to
.
) sin(
) (
) sin( ) sin(
] [
1 1 1
1 1
= = =
+ +
= =
L
k
L
k
L
k
k
k k
k
k
k
k ML
n
n
A A
n
n
A
n
n
A n h

10.5 Therefore,

< <
< <
=
. 0 ,
, 0 ,
) (

j
j
e H
j
HT

=
0
0
) (
2
1
) (
2
1
] [

d e e H d e e H n h
n j j
HT
n j j
HT HT

( )
n
n
n
n
d je d je
n j n j

) 2 / ( sin 2
) cos( 1
2
2
2
1
2
1
2
0
0
= =

if . 0 n
For , 0 = n
. 0
2
1
2
1
] 0 [
0
0
=

jd jd h
HT

Not for sale 326
Hence,

=
=
. ,
) / (
, ,
] [
0 if
2 2sin
0 if 0
2
n
n
n
n
n h
HT

Since ], [ ] [ n h n h
HT HT
= and the length of the truncated impulse response is odd, it is a Type
3 linear-phase FIR filter.
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
N=11
N=21
N=61

From the frequency response plots given above, we observe the presence of ripples at the
bandedges due to the Gibbs phenomenon caused by the truncation of the impulse response.

10.6 . Hence,

=
=
k
HT
k x k n h n x ] [ ] [ ]} [ { H
{ } { } ) ( ) ( ] [
j j
HT
e X e H n x = H F

< <
< <
=
. 0 ), (
, 0 ), (

j
j
e jX
e jX

(a) Let
{ } { { } { }. ] [ ] [n x n y H H H H = }
Hence,
Therefore,
). (
, 0 ), ( ) (
, 0 ), (
) (
4
4

j
j
j
j
e X
e X j
e X j
e Y =

< <
< <
=
]. [ ] [ n x n y =
(b) Define and
{ , ] [ ] [ n x n g H = }
]. [ ] [ * n x n h = Then
But from the Parseval's' relation in Table 3.4,
{ } . ] [ * ] [ ] [ ] [

=

=
=
l l
l l l l h g x x H
. ) ( ) (
2
1
] [ * ] [

d e G e G h g
j j

=

=
l
l l

Therefore,
{ }

d e X e X e H x x
j j j
HT
) ( ) ( ) (
2
1
] [ ] [

=

=
l
l l H

where
Since the integrand

< <
< <
=
. 0 ,
, 0 ,
) (

j
j
e H
j
HT ) ( ) ( ) (
j j j
HT
e X e X e H
is an odd
function of As a result, , . 0 ) ( ) ( ) (

d e X e X e H
j j j
HT
{ } . 0 ] [ ] [

= l
l l x x H

Not for sale 327
10.7 Its frequency response . ] [ ) (

=

=
N
n
n
LP LP
z n h z H
0
) (
j
LP
e H is shown in Figure (a)
below. A plot of the frequency response =

) (
j
HT
e H ) ( ) (
) ( ) (
2 2

+
+
j
LP
j
LP
e H e H
is shown in Figure (b) below. It is evident from this figure that ) (
j
HT
e H is the
frequency response of an ideal Hilbert transformer. Therefore, we have
0

1
_

j
H (e )
LP
2
__
_
2
__

(a)
0

1
_

2
__

_
2
__

H (e )
LP
j( )
2
__

_
j( + )
2
__

H (e )
LP
j
H (e )
HT

(b)
) ( ) ( ) (
) ( ) (
2 2

+

+ =
j
LP
j
LP
j
HT
e H e H e H
( )
2 2
0 0 0
2 2
/ /
) ( ) (
] [ ] [ ] [

= =

=
+
+ = + =

jn jn jn
N
n
LP
N
n
jn
LP
N
n
jn
LP
e e e n h e n h e n h
( ). cos ] [
2
0
2

=

=
n
N
n
jn
LP
e n h Now, for odd, n 0 2 = ) / cos(n and hence, we can drop all
odd terms in the above expression. Let M N 2 = with even and let Then, we
can rewrite the above equation as The
corresponding transfer function of the Hilbert transformer is therefore given by
N . n r 2 =
. ) cos( ] [ ) (

=

=

r j
M
r
LP
j
HT
e r r h e H
2
0
2 2
. ] [ ) ( ) cos( ] [ ) (

=

=

= =
M
n
n
LP
n
M
n
n
LP HT
z n h z n n h z H
0
2
0
2
2 1 2 2 2

10.8 Hence,
. ) (

j e H
j
DIF
=
.
2 2 2
1
] [
2

n
e
jn
e j
d e
j
d e j n h
n j n j
n j n j
DIF Therefore,
,
) cos( ) sin( ) cos(
] [
2
n
n
n
n
n
n
n h
DIF

=

=
if . 0 n
Not for sale 328
For , 0 = n
. 0
2
1
] 0 [ =

d j h
DIF

Hence,

>

=
=
. 0 | | ,
) cos(
, 0 , 0
] [
n
n
n
n
n h
DIF Since ], [ ] [ n h n h
DIF DIF
= the truncated impulse
response is a Type 3 linear-phase FIR filter. The magnitude responses of the above
differentiator for several values of M are given below:
0 0.2 0.4 0.6 0.8 1
0
1
2
3
4
/
M
a
g
n
i
t
u
d
e
M=10
M=20
M=30

10.9 . 1 2 + = M N
( )

<

=
=
otherwise. 0,
if
for
, 0 , ,
) (
) ( sin
, , 1
] [

N n M n
m n
m n
M n
n h
c
c
HP

Now,

=

+ = + = +
1
0
1
0
] [

] [

] [

] [

) (

) (

N
n
n
LP
N
n
n
HP
n
n
LP
n
n
HP LP HP
z n h z n h z n h z n h z H z H

( ) . ] [

] [

1
0

+ =
N
n
n
LP HP
z n h n h
But ] [

] [

n h n h
LP HP
+ = ,

= +
.
1 , 0
] [

] [

n=M
M , n N n
n h n h
LP HP
1,
, 0
Hence,
, ) (

) (

M
LP HP
z z H z H = +
i.e. the two filters are delay-complementary.

10.10

<
=
otherwise. , 0
, ,
) (
c j
LLP
e H

Therefore,
Not for sale 329

c
c
d e d e n h
n j n j
LLP

0
0
2
1
] [

+ +

=
c
c
n
e
jn
e
n
e
jn
e
n j n j n j n j

0
2
0

2
2
1

+
+

=

2
2
2
1
n
e e
jn
e e
n j n j n j
c
n j
c
c c c c

.
1 ) cos(
) sin(
2
n
n
n
n
c
c
c

+ =

10.11

<
=
. , 0
, ,
) (
otherwise
c j
BLDIF
e H

Hence,

c
c
c
c
n
e
jn
e
d e n h
n j n j
n j
BLDIF

2
2
1
2
1
] [

). sin(
1
) cos(
2
1
2 2
n
n
j n
n
j
n
e e
jn
e e
c c
c
n j n j n j
c
n j
c
c c c c

+ =

+
+

=

10.12 The frequency response of a causal ideal notch filter can thus be expressed as
) (
) ( ) (

j
notch
j
notch
e H e H
(
= where ) (
notch
H
(
is the amplitude response which can
be expressed as It follows then that

< <

=
. , 1
, 0 , 1
) (

o
o
notch
H
(
) (
notch
H
(
is
related to the amplitude response ) (
LP
H
(
of the ideal lowpass filter with a cutoff at
through
o

]. 1 ) ( 2 [ ) ( =
LP
H H
notch
( (
Hence, the impulse response of the ideal
notch filter is given by [ ], ] [ ] [ 2 ] [ n n h n h
LP notch
= where
. ,
) sin(
] [ < < = n
n
n
n h
o
LP

The magnitude responses of a length 41 notch filter

with a notch frequency at = 0.4 and its associated length-41 lowpass filter are shown
below.
o

Not for sale 330

0 0.2 0.4 0.6 0.8 1
0
0.5
1
1.5
/
A
m
p
lit
u
d
e

o
= 0.4

10.13 ( ) ( )

d e H e H
j
d
j
t R
2
2
1
, where ( ) [ ] .

=
M
M n
n j
t
j
t
e n h e H

Using Parsevals relation, we can write [ ] [ ]

=
=
n
d t R
n h n h
2

[ ] [ ] [ ] [ ]

=

+ =

=
+ + =
M
M n M n
d
M
n
d d t
n h n h n h n h
1
2
1
2
2
.
Now, [ ] [ ] [ ]

=
=
n
d Hann d Haan
n h n w n h
2

[ ] [ ] [ ] [ ]

+ =

= =
+ +

+
+ =
1
2
1
2
2
1 2
2
cos
2
1
2
1
M n
d
M
n
d
M
M n
d d
n h n h n h
M
n
n h

Hence,
Haan R Excess
=
[ ] [ ] [ ] [ ] [ ]

= =

+
+ =
M
M n
d d
M
M n
d R d
n h
M
n
n h n h n w n h
2
2
1 2
2
cos
2
1
2
1

[ ] [ ]

+
=
M
M n
d d
n h
M
n n h
2
2 1 2
2
cos
2

( )
2
1
1 2
2
cos 2 1
2
1

+
+ =
M
M
M

.

10.14 [ ] [ ]

=
=
n
d t R
n h n h
2
and [ ] [ ] [ ] .
2

=
=
n
d Hamm d Hamm
n h n w n h
Therefore,
Hamm R Excess
= [ ]

+
=
M
M n
d
M
n
n h
2
46 . 0
1 2
2
cos 46 . 0

[ ]

+
=
M
M n
d
M
n
n h
2
1
1 2
2
cos 46 . 0

( ) . 1
1 2
2
cos 1 2 46 . 0
2

+
+ =
M
M
M

Not for sale 331
10.15 (a) 47 . 0 =
p
, 59 . 0 =
s
, 001 . 0 =
p
, 007 . 0 =
s
, 12 . 0 = ,
1 . 43 log 20
10
= =
s s
dB
From Table 10.2, we see that for fixed-window functions, we can achieve the minimum
stopband attenuation by using Hann, Hamming, or Blackman windows. Hann will have
the lowest filter length.

53 1 2 = + = M N
Haan
since . 917 . 25
12 . 0
11 . 3
= =

M
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-140
-120
-100
-80
-60
-40
-20
0
20
/
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
Lowpass filter using Hann window

(b) 61 . 0 =
p
, 78 . 0 =
s
, 001 . 0 =
p
, 002 . 0 =
s
, 17 . 0 = ,
54 log 20
10
= =
s s
dB
From Table 10.2, we see that for fixed-window functions, we can achieve the minimum
stopband attenuation by using either Hamming, or Blackman windows. Hamming will
have the lowest filter length.

41 1 2 = + = M N
Hamm
since 53 . 19
17 . 0
32 . 3
= =

M .
Not for sale 332
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-100
-80
-60
-40
-20
0
20
/
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
Lowpass filter using Hamming window

10.16 45 . 0
1
=
p
, 65 . 0
2
=
p
, 3 . 0
1
=
s
, 8 . 0
2
=
s
, 15 . 0
2 1
= = ,
01 . 0 =
p
, 008 . 0
1
=
s
, 05 . 0
2
=
s

42 log 20
1 10 1
= =
s s
dB, 26 log 20
2 10 2
= =
s s
dB
From Table 10.2, we see that the Hann window will have minimum length and meet the
minimum stopband attenuation.
. 21
15 . 0
11 . 3
= =

M Therefore, 43 = N .
Not for sale 333
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-140
-120
-100
-80
-60
-40
-20
0
20
/
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
Bandpass filter using Hann window

10.17 3 . 0
1
=
p
, 8 . 0
2
=
p
, 45 . 0
1
=
s
, 65 . 0
2
=
s
, 15 . 0
2 1
= = ,
05 . 0
1
=
p
, 009 . 0
2
=
p
, 02 . 0 =
s
,
34 log 20
10
= =
s s
dB
From Table 10.2, we see that the Hann window will have minimum length and meet the
minimum stopband attenuation.
Not for sale 334
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-120
-100
-80
-60
-40
-20
0
20
/
M
a
g
n
i
t
u
d
e

R
e
s
p
o
n
s
e
Bandstop filter using Hann window

10.18 Consider another filter with a frequency response given by ) (
j
e G

<

=
elsewhere. , 0
, ,
) (
sin
2
, ,
) (
sin
2
, 0 , 0
) (
p s
p
s p
p
p
j
e G

Clearly
.
) (
) (

d
e dH
e G
j
j
=
Now,

d e e G n g
n j j
) (
2
1
] [

s
p
s
p
d e e d e e
j
n j
p
j
n j
p
j

) ( ) (
8

+
p
s
p
s
d e e d e e
n j
p
j
n j
p
j

) ( ) (

Not for sale 335

+

=

n j
e e
e
n j
e e
e
j
n j n j j n j n j j
p s p p s p
)
8
1

n j
e e
e
n j
e e
e
n j n j j n j n j j
s p p s p p

n
n n
n
n n
j
p s p s
) sin( ) sin( ) sin( ) sin(
4
1

( )

+
=
2
2
2
/ 2
4
) sin( ) sin(

n
j
n n
p s

( )
.
) / ( 1
1 ) 2 / cos( ) sin(
2 2

=
n
j
n n
c

Now, ]. [ ] [ n g
n
j
n h = Therefore,
.
) sin(
) / ( 1
) 2 / cos(
] [
2 2

=
n
n
n
n
n h
c

10.19
] [
1 2
4
cos
1 2
2
cos ] [ n w
M
n
M
n
n w
R GC

+
+

+
+ =

] [ 2 2
1 2
4
1 2
4
1 2
2
1 2
2
n w e e e e
R
M
n
j
M
n
j
M
n
j
M
n
j

+ +

+ + =

+

Hence,

+ =

+
+

1 2
2
1 2
2
2 2 ) ( ) (
M
j
R
M
j
R
j
R
j
GC
e e e e

. 2 2
1 2
4
1 2
4

+
+

M
j
R
M
j
R
e e

For the Hann window : = 0.5, = 0.5 and = 0. Hence,

+ =

+
+

1 2
2
1 2
2
2 ) ( 5 . 0 ) (
M
j
R
M
j
R
j
R
j
Haan
e e e e

Not for sale 336

.
1 2 2
sin
1 2 2
) 1 2 ( sin
1 2 2
sin
1 2 2
) 1 2 ( sin
) 2 / sin(
2
) 1 2 (
sin
5 . 0

+
+

+
+ +
+

+
+
+

+
=
M
M
M
M
M
M
M

For the Hamming window, = 0.54, = 0.46, and = 0. Hence,

+ =

+
+

1 2
2
1 2
2
min
92 . 0 92 . 0 ) ( 54 . 0 ) (
M
j
R
M
j
R
j
R
j
g Ham
e e e e

.
1 2 2
sin
1 2 2
) 1 2 ( sin
92 . 0
1 2 2
sin
1 2 2
) 1 2 ( sin
92 . 0
) 2 / sin(
2
) 1 2 (
sin
54 . 0

+
+

+
+ +
+

+
+
+

+
=
M
M
M
M
M
M
M

F
or the Blackmann window = 0.42, = 0.5 and = 0.08

+ =

+
+

1 2
2
1 2
2
) ( 42 . 0 ) (
M
j
R
M
j
R
j
R
j
Blackman
e e e e

1 2
4
1 2
4
16 . 0 16 . 0
M
j
R
M
j
R
e e

+
+

+
+ +
+

+
+
+

+
=
1 2 2
sin
1 2 2
) 1 2 ( sin
1 2 2
sin
1 2 2
) 1 2 ( sin
) 2 / sin(
2
) 1 2 (
sin
42 . 0
M
M
M
M
M
M
M

.
1 2
2
2
sin
1 2
2
2
) 1 2 ( sin
16 . 0
1 2
2
2
sin
1 2
2
2
) 1 2 ( sin
16 . 0

+
+
+

+
+
+
M
M
M
M
M
M

10.20 (a) ( ) [ ] [ ] [ ] [ ] [ ]

=

+ + + + = =
N
n
N n D
z N h z h z h h z n h z z H
0
2 1
2 1 0 L
We see that if then ( ) ( ) [ ,
2
1

=
+ =
N
N k
k a
k n x t P t x ] ( )

=
2
1
N
k l
N l
l k
l
k
t t
t t
t P for
2 1
N k N .
Not for sale 337
Here, we have and the solution follows if ( ) [ ]

=
N
n
n
z n h z H
0

( ) [ ] n h t P
k
= , , , 0
1
= N N N =
2
n k = , D t = , k t
l
= , and n t
k
=
Therefore, we have [ ]

=
N
n k
k
k n
k D
n h
0
for N n 0 .

(b) N = 21, D = 90/13, L = 22. , where ( ) [ ]

21
0 n
n
z n h z H [ ]

=

=
21
0
13 / 90
n k
k
k n
k
n h .

% Problem #10.20
D = 90/13;
N = 21;
for n = 0:N,
for k = 0:N,
if n ~= k,
tmp(n+1,k+1) = (D-k)/(n-k);
else
tmp(n+1,k+1) = 1;
end
end
end
h = prod(tmp');
[Gd,W] = grpdelay(h,1,512);
[H, w] = freqz(h,1,512);

figure(1);
plot(W/pi, Gd);
xlabel('\omega/\pi');
ylabel('Group Delay');
title('Group delay of z^-^D');
grid;

figure(2);
plot(w/pi, (abs(H)));
xlabel('\omega/\pi');
ylabel('Magnitude');
title('Magnitude response of z^-^D');
grid;
Not for sale 338
0 0.2 0.4 0.6 0.8 1
6.5
7
7.5
8
/
G
r
o
u
p

D
e
l
a
y
Group delay of z
-D

0 0.2 0.4 0.6 0.8 1
0.9
1
1.1
1.2
1.3
1.4
1.5
/
M
a
g
n
i
t
u
d
e
Magnitude response of z
-D

10.21 (a) where is the desired signal and
is the harmonic interference with fundamental
frequency . Now,
], [ ] [ ) sin( ] [ ] [
0
n r n s n k A n s n x
k o
M
k
k
+ = + + =

=
] [n s
) sin( ] [
0
k o
M
k
k
n k A n r + =

=
o
] ) ( sin[ ] [
0
k o
M
k
k
D n k A D n r + =

=
]. [ ) 2 sin(
0
n r k n k A
k o
M
k
k
= + =

=

(b) ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ n r D n s n r n s D n r D n s n r n s D n x n x n y + = + = =
Hence, does not contain any harmonic disturbances. ]. [ ] [ D n s n s = ] [n y
(c) .
1
1
) (
D D
D
c
z
z
z H

Thus,

jD D
jD
j
c
e
e
e H

=
1
1
) (
( )
( )
.
) sin( ) cos( 1
) sin( ) cos( 1

D j D
D j D
D D
+
+
=
Then,
( )
.
) cos( 2 1
) cos( 1 2
) (
2D D
j
c
D
D
e H

+

= A plot of ) (
j
c
e H for 22 . 0 =
o
and
is shown below: 99 . 0 =
Not for sale 339
-1 -0.5 0 0.5 1
0
0.2
0.4
0.6
0.8
1
/
A
m
p
l
i
t
u
d
e

(d)
x[n] y[n]
+
z
D

10.22
) ( 98 . 0 1
) ( 1
) (
) (
) (
z N
z N
z Q
z P
z H
D
c

= = , with 18 . 0 / 2 = D , N = 18, and 98 . 0 = .
% Problem #10.23
close all;
clear;
clc;
D = 2/.18;
N = 18;
rho = 0.98;
for n = 0:N,
for k = 0:N,
if n ~= k,
tmp(n+1,k+1) = (D-k)/(n-k);
else
tmp(n+1,k+1) = 1;
end
end
end
h = prod(tmp');
[H,w] = freqz(h,1,1024);
Hc = (1-H)./(1-(rho^D)*H);
x = sqrt((2*(1-cos(D*w)))./(1-
2*(rho^D)*cos(D*w)+rho^(2*D)));
%plot(w/pi, abs(Hc));
plot(w/pi, x); grid;
xlabel('\omega/\pi');
ylabel('Magnitude');
title(Comb filter using FIR fractional delay');
Not for sale 340
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
Comb filter using FIR fractional delay

10.23
) ( 98 . 0 ) (
) ( ) (
) (
) (
) (
1 11 13 / 90
1 11

= =
z D z z D
z D z z D
z Q
z P
z H
c
, with 11 . 11 18 . 0 / 2 = = D and N = 11.
% Problem #10.23
close all;
clear;
clc;
D = 2/0.18;
rho = 0.98;
N = floor(D);
for k = 1:N,
for n = 0:N,
p(n+1) = (D-N+n)/(D-N+k+n);
end
d(k) = ((-1)^k)*nchoosek(N,k)*prod(p);
end
[H,w] = freqz(fliplr(d)-d, fliplr(d)-(rho^D).*d , 512);
plot(w/pi, abs(H));grid;
xlabel('\omega/\pi');
ylabel('Magnitude');
title(Comb filter using allpass IIR fractional delay');

0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
Comb filter using allpass IIR fractional delay

Not for sale 341
10.24

<

+
+
<

=
elsewhere. , 0
, , 1
, , 1
, , 1
) (
p s
p s
p
s p
p s
p
p p
j
LP
e H

Now, for , 0 n

d e e H n h
n j j
LP LP
) (
2
1
] [

+
+ +

+ =

s
p
p
s
p
p
d e d e d e
n j
p
n j
p
n j

1 1
2
1

+
+

=

s
p
p
s
s
s
d e d e d e
n j
p
n j
p
n j

2
1

+
+
+

=
p
s
s
p
n
e
jn
e
n
e
jn
e
n
n
n j
n j
p
n j
n j
p
s

2 2
) (
1
) (
1 ) sin( 2
2
1

+ =

2 2
1 ) sin( 2
2
1
n
e e
jn
e
n
e e
jn
e
n
n
n j
n j
n j
n j
n j n j
s
s
p
s
p
s s

+ =
2
) cos( ) cos(
) sin( 2 ) sin( 2
2
1
n
n n
n
n
n
n p s
s s

=
2 2
) cos(
) cos(
1
n
n
n
n
s
p

=
2 2
) ) 2 / cos(( ) ) 2 / cos(( 1
n
n
n
n
c c

.
) sin( ) 2 / sin( 2
n
n
n
n
c

=

Next, for , 0 = n

2
1
) (
2
1
] 0 [ = =

d e H h
j
LP LP
(area under the curve)
( )
.
2 2
1

c
p s
=

=
2 +

Not for sale 342
Hence,

=
=
0. if
2sin(
0, if
n
n
n
n
n
n
n h
c
c
LP
,
) sin( ) 2 /
,
] [

An alternate approach to solving this problem is as follows. Consider the frequency response

< <
< <

= =
elsewhere. , 0
, ,
1
, ,
1

, , 0
) (
) (
p s
s p
p p
j
LP j
d
e H d
e G

Its inverse DTFT is given by

) (
2
1
] [

d e e G n g
n j j

d e d e
n j n j
s
p
p
s

=

1
2
1 1
2
1

jn
n j
e
jn
n j
e
s
p
p
s

2
1

( ) ) cos( ) cos(
1
n n
n j
s p

.
Thus,
] [ ] [ n g
n
j
n h
LP
=

( ) ) cos( ) cos(
1
2
n n
n
s p

= n n
n
s c
2
cos
2
cos
1
2

. 0 ,
) sin( ) 2 / sin( 2

= n for
n
n
n
n
c

For , 0 = n
. ] [

=
c
LP
n h

10.25 Consider the case when the transition region is approximated by a second order spline. In
this case the ideal frequency response can be constructed by convolving an ideal, no-
transition-band frequency response with a triangular pulse of width
p s
= ,
which in turn can be obtained by convolving two rectangular pulses of width . In
the time domain this implies that the impulse response of a filter with transition band
approximated by a second order spline is given by the product of the impulse response of
an ideal low pass filter with no transition region and square of the impulse response of a
rectangular pulse. Now,
2 /
Not for sale 343
n
n
n H
c
ideal LP

) sin(
] [
) (
=
and
4 /
) 4 / sin(
] [
n
n
n H
rec

= . Hence,
. ( )
) (
] [ ] [ ] [ n H n H n H
rec ideal LP LP
=
2
Thus for a lowpass filter with a transition region approximated by a second order spline

=
otherwise.
sin(
0, = n if
,
) sin(
4 /
) 4 /
,
] [
2
n
n
n
n
n h
c
c
LP

Similarly the frequency response of a lowpass filter with the transition region specified by a
-th order spline can be obtained by convolving in the frequency domain an ideal filter with no
transition region with rectangular pulses of width Hence,
, where the rectangular pulse is of width Thus
P
P
. / P
(
P
rec ideal LP LP
n H n H n H ] [ ] [ ] [
) (
= ) . / P

=
otherwise.
sin(
if
,
) sin(
2 /
) 2 /
0 ,
] [
n
n
P n
P n
, = n
n h
c
P
c
LP

10.26 From Step 2, we have . ) ( ) ( ) (
) (

jN jN jN j
e F e e G e G
F
s

+ = =
( (

The amplitude response ) ( G
(
has been obtained by raising the amplitude response
) ( F
(
by and hence, the filter has double zeros in the stopband.
( ) F
s
) (z G

Not for sale 344
We may factorize as follows: where is a real-coefficient
minimum-phase FIR lowpass filter with half the degree of the original Since,
), ( ) ( ) (
1
= z H z H z z G
m m
N
) (z H
m
). (z H , 0 ) ( G
(

the amplitude response ) (
m
H
(
of the minimum-phase filter does not oscillate about
unity in the passband. Since the original frequency response was raised by
) (z H
m
( )
,
F
s
) (
m
H
(
must be
normalized by a factor . 1
s
+ Therefore,

For ) (
m
H
(
, we can see
( )
s
s F
s

+
=
1
2
and
( )
1
1
1 1
1
1

+
+ =
+
+ +
=
s
p
s
s p
F
p

.

10.27 (a) N = 1 and hence, . ) (
1 0
t t x
a
+ = Without any loss of generality, for . 5 = L we first
fit the data set , 5 5 ]}, [ { k k x by the polynomial t t x
a 1 0
) ( + = with a minimum
mean-square error at , 5 , , 1 , 0 , 1 , , 4 , 5 K K = t , and then replace with a new value ] 0 [ x
. ) 0 ( ] 0 [
0
= = x x
Now, the mean-square error is given by We set ( ) . ] [ ) , (
5
5
2
1 0 1 0
=
=
k
k k x
0
) , (
0
1 0
=

and
0
) , (
1
1 0
=

which yields and

= +
= =
5
5
5
5
1 0
], [ 11
k k
k x k
= +
= = =
5
5
5
5
2
1
5
5
0
]. [
k k k
k x k k k
From the first equation we get

=
= =
5
5
0
]. [
11
1
] 0 [
k
k x x In the general case we thus
Not for sale 345
have

=
= =
5
5
0
] [
11
1
] [
k
k x n x which is a moving average filter of length 11.
(b) and hence, Here, we fit the data set
by the polynomial with a minimum mean-square
error at and then replace with a new value
, 2 = N . ) (
2
2 1 0
t t t x
a
+ + = ]}, [ { k x
, 5 5 k
2
, 5 , , 1 , 0 , 1 , , 4 , 5 K K ] 0 [ x
2 1 0
) ( t t t x
a
+ + =
= t
. ) 0 (
0
=
a
x ] 0 [ = x
5
The mean-square error is now given by
We set
( ) ( ) . ] [ , ,
5
2
2
2 1 0 2 1 0
=
=
k
k k k x , 0
) , , (
0
2 1 0
=

, 0
1
2 1 0
=

) , , (
and
, 0
2
2 1 0
=

) , , (
which yields
From the
first and the third equations we then get

=
= +
5
5
2 0
], [ 110 11
k
k x

=
=
5
5
1
], [ 110
k
k x k

=
= +
5
5
2
2 0
]. [ 1958 110
k
k x k

2
5
5
2
5
5
0
) 110 ( ) 11 1958 (
] [ 110 ] [ 1958

=

= = k k
k x k k x

( ) ]. [ 5 89
429
1
5
5
2
k x k
k

=
=

Hence, here we replace ] [n x with a new value
0
] [ = n x which is a weighted combination of
the original data set : 5 5 ]}, [ { k k x

( ) ] [ 5 89
429
1
] [
5
5
2
k n x k n x
k
=

=

] [ 89 ] 1 [ 84 ] 2 [ 69 ] 3 [ 44 ] 4 [ 9 ] 5 [ 36
429
1
( n x n x n x n x n x n x + + + + + + + + + + =

. ] 5 [ 36 ] 4 [ 9 ] 3 [ 44 ] 2 [ 69 ] 1 [ 84 ) + + + + n x n x n x n x n x

(c) The impulse response of the FIR filter of Part (a) is given by

{ }, 1 1 1 1 1 1 1 1 1 1 1
11
1
] [
1
= n h

whereas, the impulse response of the FIR filter of Part (b) is given by

{ }. 36 9 44 69 84 89 84 69 44 9 36
429
1
] [
1
= n h

The corresponding frequency responses are given by

,
11
1
) (
5
5
1
=

=
k
k j j
e e H

and
( ) . 5 89
429
1
) (
5
5
2
2
=

=
k
k j j
e k e H

Not for sale 346
A plot of the magnitude responses of these two filters are shown below from which it can
be seen that the filter of Part (b) has a wider passband and thus provides smoothing over a
larger frequency range than the filter of Part (a).
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
H
1
(z)
H
2
(z)

10.28 ] 2 [ 46 ] 3 [ 21 ] 4 [ 3 ] 5 [ 5 ] 6 [ 6 ] 7 [ 3
320
1
] [ { + + + = n x n x n x n x n x n x n y
] 4 [ 3 ] 3 [ 21 ] 2 [ 46 ] 1 [ 67 ] [ 74 ] 1 [ 67 + + + + + + + + + + n x n x n x n x n x n x
. ] 7 [ 3 ] 6 [ 6 ] 5 [ 5 } + + + n x n x n x
Hence,
{

3 4 5 6 7
3
21 3 5 6 3
320
1
) (
) (
) (
j j j j j
j
j
j
e e e e e
e X
e Y
e H

+ + = =

}
7 6 5 4 3 2 2
3 6 5 3 21 46 67 74 67 46
j j j j j j j j j
e e e e e e e e e + + + + + +
.
{ } ) 7 cos( 3 ) 6 cos( 6 ) 5 cos( 5 ) 4 cos( 3 ) 3 cos( 21 ) 2 cos( 46 cos 67 74
160
1
+ + + + =

}. ) 7 cos( 3 ) 6 cos( 6 ) 5 cos( 5
The magnitude response of the above FIR filter is plotted below (solid line) along
with that of the FIR filter of Part (b) of Problem 10.27 (dashed line). Note that
both filters have roughly the same passband but the Spencer's filter has very large
attenuation in the stopband and hence it provides better smoothing than the filter of Part
(b).
) (
3
z H
) (
2
z H
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
H
3
(z)
H
2
(z)

Not for sale 347
10.29 (a) . Now . 3 = L
3
3
2
2 1
) ( x x x x P + + = 0 ) 0 ( = P is satisfied by the way has
been defined. Also to ensure
) (x P
1 ) 1 ( = P we require 1
3 2 1
= + + . Choose 1 = m and
Since . 1 = n , 0
) (
0
=
= x
dx
x dP
hence , 0 3 2
0
2
3 2 1
= + +
= x
x x implying 0
1
= . Also
since , 0
) (
1
=
= x
dx
x dP
hence 0 3 2
3 2 1
= + + . Thus solving the three equations:
, ,and 1
3 2 1
= + + 0
1
= 0 3 2
3 2 1
= + +
we arrive at , , and
1
0
2
3
3
2. Therefore, . 2 3 ) (
3 2
x x x P =

(b) Hence, . Choose and . 4 = L
4
4
3
3
2
2 1
) ( x x x x x P + + + = 2 = m 1 = n
(alternatively one can choose 1 = m 2 and = n
=
for better stopband performance ). Then,
1 ) 1 ( P . 1
4 3 2 1
= + + + Also,
, 0 4
3
4
x 3 2 0
) (
0
2
3 2 1
0
= + + + =
=
=
x
x
x x
dx
x dP

, 0 12 6 2 0
) (
0
2
4 3 2
0
2
2
= + + =
=
=
x
x
x x
dx
x P d

. 0 4 3 2 0
) (
4 3 2 1
1
= + + + =
=

x
dx
x dP

Solving the above four simultaneous equations we get and
1
0,
2
0,
3
4,
4
3.
Therefore, . 3 4 ) ( x x x P =
4 3
(c) Hence Choose and . 5 = L . ) (
5
5
4
4
3
3
2
2 1
x x x x x x P + + + + = 2 = m 2 = n .
Following a procedure similar to that in parts (a) and (b) we get
and
1
0, 0, 10,
15, 6.
2 3
4 5

10.30 From Eq. (7.102) we have Now

=
=
M
k
k k c H
1
). sin( ] [ ) (
(
( )

=
+
= =
= = =
M
k
k
M
k
M
k
k k c k k k c k k c H
1
1
1 1
). ( ) 1 ]( [ ) cos( ) ( sin ] [ ) ( sin ] [ ) (
(
Thus, ) ( ) ( = H H
( (
implies or
equivalently, which in turn implies that

= =
+
=
M
k
M
k
k
k k c k k c
1 1
1
), sin( ) 1 ( ] [ ) sin( ] [
( )

=
+
=
M
k
k
k k c
1
1
, 0 ) sin( ] [ ) 1 ( 1 0 ] [ = k c for
. , 6 , 4 , 2 K = k
Not for sale 348
But from Eq. (7.103) we have , 1 ], [ 2 ] [ M k k M h k c = or, ]. [ ] [
2
1
k M c k h = For k even,
i.e., 0 ] 2 [ ] 2 [ , 2
2
= = = R M c R h R k
1
if M is even.
10.31 (a) Thus, . 1 0 ), ( ) ( ] [
/ 2
= = M k e H e H k H
M k j
j
k

, ] [
1
] [
1
0

=

=
M
k
kn
M
W k H
M
n h
where .
/ 2 M k j
M
e W

=
Now, . ] [
1
] [
1
] [ ) (
1
0
1
0
1
0
1
0
1
0

=

= = =
M
k
M
n
n kn
M
M
n
n
M
k
kn
M
M
n
n
z W k H
M
z W k H
M
z n h z H
We can write

=

=

=
M n
n kn
M
n
n kn
M
M
n
n kn
M
z W z W z W
0
1
0
( ) .
1
1
1
1
0 0 0

= = =

z W
z
z W z z W z W z W
k
M
M
n
n kn
M
M
n
n kn
M
M kM
M
n
n kn
M

Therefore, .
1
] [ 1
) (
1
0
1

=
M
k
k
M
M
z W
k H
M
z
z H
(b)
H
M
H
M
H[M 1]
M
x[n]
y[n]
1
1 z
1
1
1 z
1
e
j2 / M
1
1 z
1
e
j2 (M 1)/ M
1 z
M

(c) Note . ] [
1
1
] [ 1
) (
1
0
1
0
1
0
1

=

=
M
k
M
n
n kn
M
M
k
k
M
M
z W k H
M
z W
k H
M
z
z H
Not for sale 349
On the unit circle the above reduces to . ] [
1
) (
1
0
1
0

=
M
k
M
n
n j kn
M
j
e W k H
M
e H

For
we then get from the above , / 2 M j l =

= =

=
0 0
/ 2 / 2
1
] [ ) (
k n
M n kn
M
M j
e W
M
k H e H
l l
1 1 M M

= =

=
0 0
1
] [
k n
n
M
kn
M
W W
M
k H
l
1 1 M M
.
1
] [
0 0
) (

= =

=
k n
n k
M
W
M
k H
l
1 1 M M
Using the identity of Eq.
(5.23) of text we observe that

=
=

=

otherwise. , 0
, if , 1
1
0
) (
k
W
M
n
n k
M
l
l
1 M

Hence, ]. [ ) (
/ 2
l
l
H e H
M j
=

10.32 (a) For Type 1 FIR filter, . ) ( ) (
2
) 1 (

j
M
j
j
e H e e H

= Since in the frequency

sampling approach we sample the DTFT at ) (
j
e H M points given by ,
2
M
k
=
therefore , 1 0 M k , ) ( ) ( ] [
/ ) 1 ( 2 / 2 / 2 M M k j M k j
d
M k j
e e H e H k H

= =

Since the filter is of Type 1, . 1 0 M k 1 M is even, thus, .
Moreover, being real, Thus,
. 1
2 / ) 1 ( 2
=
M k j
e

] [n h ). ( * ) (
j j
e H e H = , ) ( ) (
2 / ) 1 ( j M j j
e H e e H

=
Hence, . 2 <

=
=

+ +
=

. 1 , ,
2
3
2
1
2 / ) 1 )( ( 2 / 2
,
2
1
2 / ) 1 ( 2 / 2
, ) (
, , 2 , 1 , 0 , ) (
] [
M
M M
k
M M k M j M k j
d
M
M M k j M k j
d
e e H
k e e H
k H
K
K

(b) For the Type 2 FIR filter

+ =
=
=
=

. 1 , , 1 , ) (
, , 0
, , 2 , 1 , 0 , ) (
] [
2
2 / ) 1 )( ( 2 / 2
2
,
2
1
2 / ) 1 ( 2 / 2
M k e e H
k
k e e H
k H
M
M M k M j M k j
d
M
M
M M k j M k j
d
K
K

10.33 (a) The frequency spacing between 2 consecutive DFT samples
is given by
. 72788 . 1 55 . 0 = =
p
. 3307 . 0
19
2
=

The desired passband edge is between the frequency samples at

19
5
2 = and .
19
6
2 = Therefore, the 19-point DFT is given by
Not for sale 350

=
=
=

. 12 , , 6 , 0
, 18 , , 14 , 13 , 5 , , 1 , 0 ,
] [
9 ) 19 / 2 (
K
K K
k
k e
k H
k j

A 19-point IDFT of the above DFT samples yields the impulse response coefficients
given below in ascending powers of :
1
z

Columns 1 through 10
-0.0037 -0.0022 0.0224 -0.0211 -0.0231 0.0674
-0.0316 -0.1128 0.2888 0.6316

Columns 11 through 19
0.2888 -0.1128 -0.0316 0.0674 -0.0231 -0.0211
0.0224 -0.0022 -0.0037

(b)
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e

% Problem #10.33
close all;
clear;
clc;

ind = 1;
for k = 0:5,
H(ind) = exp(-i*2*pi*9*k/19);
ind = ind + 1;
end

for k = 6:12,
H(ind) = 0;
ind = ind + 1;
end
for k = 13:18,
H(ind) = exp(-i*2*pi*9*k/19);
ind = ind + 1;
end
h = ifft(H);

figure(1);
stem(real(h));
[FF, w] = freqz(h, 1, 512);
Not for sale 351
figure(2);
plot(w/pi, abs(FF)); axis([0 1 0 1.2]);grid;
ylabel('Gain, in dB'); xlabel('\omega/\pi');

10.34 (a) The frequency spacing between 2 consecutiveDFT samples
is given by
. 09956 . 1 35 . 0 = =
p
. 1611 . 0
39
2
=

The desired passband edge is between the frequency samples

at
39
6
2 = and
39
7
2 = . Therefore, the 39-point DFT is given by

=
=
=

. 31 , , 7 , 0
, 38 , , 33 , 32 , 6 , , 1 , 0 ,
] [
19 ) 39 / 2 (
K
K K
k
k e
k H
k j
A 39-point IDFT of the above DFT samples yields the impulse response coefficients
given below in ascending powers of :
1
z

Columns 1 through 10
0.0006 0.0031 0.0017 -0.0054 -0.0091 -0.0010
0.0128 0.0146 -0.0034 -0.0237

Columns 11 through 20
-0.0192 0.0134 0.0405 0.0227 -0.0362 -0.0753
-0.0249 0.1222 0.2870 0.3590

Columns 21 through 30
0.2870 0.1222 -0.0249 -0.0753 -0.0362 0.0227
0.0405 0.0134 -0.0192 -0.0237

Columns 31 through 39
-0.0034 0.0146 0.0128 -0.0010 -0.0091 -0.0054
0.0017 0.0031 0.0006

(b)
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e

% Problem #10.34
close all;
clear;
clc;
ind = 1;
for k = 0:6,
Not for sale 352
H(ind) = exp(-i*2*pi*19*k/39);
ind = ind + 1;
end
for k = 7:31,
H(ind) = 0;
ind = ind + 1;
end
for k = 32:38,
H(ind) = exp(-i*2*pi*19*k/39);
ind = ind + 1;
end

h = ifft(H);
figure(1);
stem(real(h));
[FF, w] = freqz(h, 1, 512);
figure(2);
plot(w/pi, abs(FF)); axis([0 1 0 1.2]); grid;
xlabel('\omega/\pi'); ylabel('Gain, dB');

10.35 By expressing where T
n
(x) is the -th order Chebyshev
polynomial in
), (cos ) cos(
n
T n = ) (x T
n
n
, x we first rewrite Eq. (10.48) in the form:
. ) ( cos ) cos( ] [ ) (
0 0

= =
= =
M
n
n
n
M
n
n n a H
(
Therefore, we can rewrite Eq. (10.70) repeated below for convenience
[ ] , 2 1 , ) 1 ( ) ( ) ( ) ( + = M i D H P
i
i i i

in a matrix form as
.
) (
) (
) (
) (
) ( / ) 1 ( ) ( cos ) cos( 1
) ( / ) 1 ( ) ( cos ) cos( 1
) ( / 1 ) ( cos ) cos( 1
) ( / 1 ) ( cos ) cos( 1
2
1
2
1
1
0
2
1
2 2
1 1 1
2 2 2
1 1 1

+
+
+
+
+ +
+ + +
M
M M
M
M
M
M
M
M
M
M
M
M
M
M
D
D
D
D
P
P
P
P

M
L
L
M M O M M
L
L
Note that the coefficients are different from the coefficients of Eq. (10.70). To
determine the expression of we use Cramer's rule arriving at
} {
i
]} [ { i a

, where
,
) ( / ) 1 ( ) ( cos ) cos( 1
) ( / ) 1 ( ) ( cos ) cos( 1
) ( / 1 ) ( cos ) cos( 1
) ( / 1 ) ( cos ) cos( 1
det
2
1
2 2
1 1 1
2 2 2
1 1 1
+
+
+ +
+ + +

=
M
M
M
M
M
M
M
M
M
M
M
M
P
P
P
P

L
L
M M O M M
L
L
and
Not for sale 353
.
) ( ) ( cos ) cos( 1
) ( ) ( cos ) cos( 1
) ( ) ( cos ) cos( 1
) ( ) ( cos ) cos( 1
2 2 2
1 1 1
2 2 2
1 1 1
+ + +
+ + +
=
M M
M
M
M M
M
M
M
M
D
D
D
D

L
L
M M O M M
L
L
.
Expanding both determinants using the last column we get and ) (
1
2
1
+
+
=

=
i
M
i
i
D b

,
) (
) 1 (
1
2
1
i
i
M
i
i
P
b

+
=

=

where
.
) ( cos ) ( cos ) cos( 1
) ( cos ) ( cos ) cos( 1
) ( cos ) ( cos ) cos( 1
) ( cos ) ( cos ) cos( 1
) ( cos ) ( cos ) cos( 1
det
2 2
2
2
1 1
2
1
1 1
2
1
2 2
2
2
1 1
2
1
+ + +
+ + +

=
M
M
M M
i
M
i i
i
M
i i
M
M
i
b

L
M O M M M
L
L
M O M M M
L
L

The above matrix is seen to be a Vandermonde matrix and is determinant is given by
Define ). cos (cos
,
,
l
l
l l
=

>
i k
k k
k i
b .
2
1

=
=
M
i r
r
r
i
i
b
b
c It can be shown by induction that
.
cos cos
1
1

=

=
i n
n
n i
i
c

2 + M
Therefore,
) (
) 1 (
) (
2
1
1
i
i
M
i
i
i
i i
P
b
D b

+
=
=
2 M+
.
) (
) 1 (
) ( ) (
) ( ) ( ) (
2
1
2
2
2
1
1
2 2 2 2 1 1
+
+
+
+ +

+ +
+ + +
=
M
M
M
M M
P
c
P
c
P
c
D c D c D c

L
L

10.36 ( )

=
stopband.
passband, 1

s
p W ( )

=
. 55 . 0 5 . 4
, 45 . 0 0 1

W

Not for sale 354
10.37 ( )

=
stopband.
passband, 1

s
p W ( )

=
. 7 . 0 4 . 3
, 55 . 0 0 1

W

10.38 ( )

=
. 82 . 0 5
, 7 . 0 55 . 0 1
, 44 . 0 0 43 . 1
,
, 1
, 0
2
2
2 1
1
1

s
s
p
p p
s
s
p
W

10.39 It follows from Eq. (10.22) that the impulse response of an ideal Hilbert transformer is an
antisymmetric sequence. If we truncate it to a finite number of terms between M n M
the impulse response is of length ) 1 2 ( + M which is odd. Hence the FIR Hilbert transformer
obtained by truncation and satisfying Eq. (10.90) cannot be satisfied by a Type 4 FIR filter.

10.40 (a) Thus, . ] [ ) (
1
0

=

=
N
n
n
z n x z X
,
) (
) (
1
] [ ) ( ) (
1
0
1
1
1
1
1
1
z D
z P
z
z
n x z X z X
N
n z
z
z
(
(
(
(
(
(
(
=

+
= =

+
=

where
, ) ( ) 1 ]( [ ] [ ) (
1 1 1
1
0
1 n n N
N
n
z z n x z n p z P

=

+ = =

( ( ( (
and
. ) 1 ( ] [ ) (
1 1
1
0

=

= =

N
N
n
n
z z n d z D
( ( (

(b) ,
] [
] [
) (
) (
) ( ] [
/ 2
/ 2
k D
k P
z D
z P
z X k X
N k j
e z
N k j
e z
(
(
(
(
(
(
(
( = = =
=
=

where
N k j
e z
z P k P
/ 2
) ( ] [

=
= (
(
(
is
the -point DFT of the sequence N ] [n p and
N k j
e z
z D k D
/ 2
) ( ] [

=
= (
(
(
is the -point DFT
of the sequence
N
]. [n d
(c) Let and [ ]
T
N p p p ] 1 [ ] 1 [ ] 0 [ = L P [ ] . ] 1 [ ] 1 [ ] 0 [
T
N x x x = L X Without
any loss of generality, assume 4 = N in which case

=

=
0
] [ ) (
n
n
z n p z P
( (
3
( ) ] 3 [ ] 2 [ ] 1 [ ] 0 [ x x x x + =
3 2
( )
1 2 2 2
] 3 [ 3 ] 2 [ ) 2 ( ] 1 [ ) 2 1 ( ] 0 [ 3

+ + + + + z x x x x
(

( )
2 2 2 2
] 3 [ 3 ] 2 [ ) 2 1 ( ] 1 [ ) 2 ( ] 0 [ 3

+ + + + z x x x x
(

Not for sale 355
( ) . ] 3 [ ] 2 [ ] 1 [ ] 0 [
3 2 3
+ + + z x x x x
(
Equating like powers of
1
z
(
we can write
where , X Q P = [ ] , ] 3 [ ] 2 [ ] 1 [ ] 0 [
T
p p p p = P [ ]
T
x x x x ] 3 [ ] 2 [ ] 1 [ ] 0 [ = X and
.
1
3 2 1 ) 2 ( 3
3 ) 2 ( 2 1 3
1
2 2 3
2 2 2
2 2 2

+ +
+ +

=

Q
3 2
It can be seen that the elements , 3 , 0 ,
,
s r q
s r
q , of the 4 matrix Q can be
determined as follows:
r,s
4
(i) The first row is given by , ) (
, 0
s
s
q =
(ii) The first column is given by , ) (
)! 3 ( !
! 3
) (
3
0 ,
r r
r r
r r
C q

= = and
(iii) the remaining elements can be obtained using the recurrence relation
.
, 1 1 , 1 , 1 , s r s r s r s r
q q q q

+ =
In the general case, we only change the computation of the elements of the first column
using the relation . ) (
)! 1 ( !
)! 1 (
) (
1
0 ,
r r
r
N
r
r N r
N
C q

= =

M10.1 The impulse response coefficients of the truncated FIR highpass filter with cutoff
frequency at can be generated using the following MATLAB statements: 4 . 0
n = -M:M;
num = -0.4*sinc(0.4*n);
num(M+1) = 0.6;
The magnitude responses of the truncated FIR highpass filter for two values of M are
shown below:
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
M=5
M=20

Not for sale 356
M10.2 The impulse response coefficients of the truncated FIR bandpass filter with cutoff
frequencies at 0.7 and 0.3 can be generated using the following MATLAB statements:
n = -M:M;
num = 0.7*sinc(0.7*n) - 0.3*sinc(0.3*n);
The magnitude responses of the truncated FIR bandpass filter for two values of M are shown
below:
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
M=5
M=20

M10.3 The impulse response coefficients of the truncated Hilbert transformer can be generated
using the following MATLAB statements:
n = 1:M;
c = 2*sin(pi*n/2).*sin(pi*n/2);b = c./(pi*n);
num = [-fliplr(b) 0 b];
The magnitude responses of the truncated Hilbert transformer for two values of M are
shown below:
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
M=5
M=20

M10.4
% Problem #M10.4
% Cascade of 2 boxcar filters of length 4
K = 2;N = 4;b = firgauss(K,N);
figure(1);
stem(b);xlabel(n);ylabel(h[n]);
title('Cascade of 2 boxcar filters of length 4');

Not for sale 357
% Cascade of 4 boxcar filters of length 4
K = 4;N = 4;b = firgauss(K,N);
figure(2);
stem(b);xlabel(n);ylabel(h[n]);
title('Cascade of 4 boxcar filters of length 4');

% Cascade of 2 boxcar filters of length 12
K = 2;N = 12;b = firgauss(K,N);
figure(3);
stem(b);xlabel(n);ylabel(h[n]);
title('Cascade of 2 boxcar filters of length 12');

% Cascade of 4 boxcar filters of length 12
K = 4;N = 12;b = firgauss(K,N);
figure(4);
stem(b);xlabel(n);ylabel(h[n]);
title('Cascade of 4 boxcar filters of length 12');
1 2 3 4 5 6 7
0
1
2
3
4
n
h
[
n
]
Cascade of 2 boxcar filters of length 4

0 5 10 15
0
10
20
30
40
50
n
h
[
n
]
Cascade of 4 boxcar filters of length 4

0 5 10 15 20 25
0
2
4
6
8
10
12
n
h
[
n
]
Cascade of 2 boxcar filters of length 12

0 10 20 30 40 50
0
200
400
600
800
1000
1200
n
h
[
n
]
Cascade of 4 boxcar filters of length 12

We can see that by increasing either K or N, the approximation to a Gaussian function
gets better. It is noted that increasing the number of boxcar filters K to a number greater
than 3 greatly affects the Gaussian shape of the impulse response.

M10.5 % Problem #M10.05
N = 36;fc = 0.2*pi;
M = N/2;
n = -M:1:M;t = fc*n;
lp = fc*sinc(t);
Not for sale 358
b = 2*[lp(1:M) (lp(M+1) - 0.5) lp((M+2):N+1)];
bw = b.*hamming(N+1)';
[h2, w] = freqz(bw, 1, 512);
plot(w/pi, abs(h2));axis([0 1 0 1.2]);
xlabel('\omega/\pi');ylabel('Magnitude');
title(['\omega_c = ', num2str(fc), ', N = ', num2str(N)]);
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e

c
= 0.62832, N = 36

M10.6 Its approximation over the range . . . . ) ( 5 5 05 4 2 3
2
+ = x x x D 2 3 x is given by
We want to minimize the peak value of the absolute error, i.e.,
minimize
. ) ( x a a x A
1 0
+ =
. . . . max x a a x x
x
1 0
2
2 3
5 5 05 4 2 3 +

Since there are 3 unknowns,
and we need 3 extremal points on , which we arbitrarily choose as
, ,
1 0
a a
, x , 3
1
= x , 0
2
= x
and We then solve the 3 linear equations:
This leads to whose solution yields
. 2
3
= x . , , ), ( ) ( 3 2 1 1
1 0
= = + l
l
l
x D x a a
,
.
.
.

4 15
5 5
15 11
1 2 1
1 0 1
1 3 1
1
0
a
a
, . , . 85 0 1 4
1 0
= = a a
and A plot of the corresponding error is shown
below in Figure (c).
. .6 9 = 6 9 2 3 2 3
2
1
. . . ) ( + = x x x E
-3 -2 -1 0 1 2
-10
-5
0
5
10
x
E
r
r
o
r
Result of first guess

-3 -2 -1 0 1 2
-10
-5
0
5
10
x
E
r
r
o
r
Result of second guess

(c) (d)

Not for sale 359

After looking at , we move the second extremal point to the location where ) (x
1
E
2
x
is a minimum. The next extrtemal points are therefore given by ) (x
1
E , 3
1
= x
and The new values of the unknowns are obtained by solving , .5 0
2
= x . 2
3
= x
, which yields
.
.
.
.

4 15
725 6
15 11
1 2 1
1 5 0 1
1 3 1
1
0
a
a
, . , . 85 0 7 3
1 0
= = a a and A plot
of the corresponding error is shown on the previous page in
Figure (d).
. 10 =
2 9 2 3 2 3
2
2
. . . ) ( + = x x x E

% Problem #M10.06
x = [-3 0 2];
d = 3.2.*x.^2 + 4.05.*x-5.5;
D = d';
A = [1 -3 1;1 0 -1;1 2 1];
C = inv(A)*D;

y = -3:0.05:2;
E = 3.2.*y.^2 + 4.05.*y - 5.5 - C(1) - C(2).*y;

% Results of first guess
figure(1);
plot(y,E);
axis([-3 2 -12 12]);
xlabel('x');
ylabel('Error');
title('Result of first guess');
hold on;
plot([-3 -3], [E(1) E(1)], 'o');
plot([2 2], [E(end) E(end)], 'o');
plot([0 0], [E(61) E(61)], 'o');
hold off;

x = [-3 -0.5 2];
d = 3.2.*x.^2 + 4.05.*x-5.5;
D = d';
A = [1 -3 1;1 -0.5 -1;1 2 1];
C = inv(A)*D;

y = -3:0.05:2;
E = 3.2.*y.^2 + 4.05.*y - 5.5 - C(1) - C(2).*y;

% Results of second guess
figure(2);
plot(y,E);
axis([-3 2 -12 12]);
xlabel('x');
ylabel('Error');
Not for sale 360
title('Result of second guess');
hold on;
plot([-3 -3], [E(1) E(1)], 'o');
plot([2 2], [E(end) E(end)], 'o');
plot([-0.5 -0.5], [E(51) E(51)], 'o');
hold off;

M10.7 . Its approximation over the range is given by
We want to minimize the peak value of the absolute error, i.e.,
minimize
( ) 5 5 8 2 0 5
2 3
. . + + = x x x x D 2 2 x
. ) (
2
2 1 0
x a x a a x A + + =
. . . max
2
2 1 0
2 3
2 2
5 5 8 2 0 5 x a x a a x x x
x
+ +

Since there are 4
unknowns, and , , ,
2 1 0
a a a , we need 4 extremal points on , which we arbitrarily
choose as
x
, 2
1
= x , 1
2
= x , 1
3
= x and . 2
4
= x We then solve the 4 linear equations:
whose solution yields
. , , , ), ( ) ( 4 3 2 1 1
2
2 1 0
= = + + l
l
l
x D x a x a a
,
.
.
.
.

3 19
3 8
3 2
7 28
1 4 2 1
1 1 1 1
1 1 1 1
1 4 2 1
2
1
0
a
a
a
, . , , . 2 0 7 5 5
2 1 0
= = = a a a
and A plot of the corresponding error is shown below in
Figure (e). We observe that these values maximize the error ( = 10).
. 10 = x x x 15 5
3
1
+ = ) ( E
-2 -1 0 1 2
-10
-5
0
5
10
x
E
r
r
o
r
Result of first guess

% Problem #M10.07
x = [-2 -1 1 2];
d = -5.*x.^3 - 0.2.*x.^2 + 8.*x + 5.5;
D = d';
A = [1 -2 4 1;1 -1 1 -1;1 1 1 1;1 2 4 -1];
C = inv(A)*D;

y = -2:0.05:2;
E = -5.*y.^3 - 0.2.*y.^2 + 8.*y + 5.5 - C(1) - C(2).*y -
C(3).*y.^2;

% Results of first guess
figure(1);
Not for sale 361
plot(y,E);
axis([-2 2 -12 12]);
xlabel('x');
ylabel('Error');
title('Result of first guess');
hold on;
plot([-2 -2], [E(1) E(1)], 'o');
plot([2 2], [E(end) E(end)], 'o');
plot([-1 -1], [E(21) E(21)], 'o');
plot([1 1], [E(1) E(1)], 'o');
hold off;

M10.8
18
8
=
p
,
18
12
=
s
,
18
10
=
T

% Problem #M10.8
wp = 4*(2*pi)/18;
ws = 6*(2*pi)/18;
wc = (wp + ws)/2;
dw = ws - wp;
% Hamming
M = ceil(3.32*pi/dw);N = 2*M+1;n = -M:M;
num = (6/18)*sinc(6*n/18);
wh = hamming(N)';b = num.*wh;

figure(1);
k=0:2*M:stem(k,b);
title('Impulse Response Coefficients');
xlabel('Time index n'); ylabel('Amplitude');

figure(2);
[h, w] = freqz(b,1,512);
plot(w/pi, 20*log10(abs(h))); grid;
xlabel('\omega/\pi'); ylabel('Gain, in dB');
title('Lowpass filter designed using Hamming window');
axis([0 1 -80 10]);

% Hann
M = ceil(3.11*pi/dw);N = 2*M+1;n = -M:M;
num = (6/18)*sinc(6*n/18);
wh = hann(N)';b = num.*wh;

figure(3);
k=0:2*M:stem(k,b);
title('Impulse Response Coefficients');
xlabel('Time index n'); ylabel('Amplitude');

figure(4);
[h, w] = freqz(b,1,512);
plot(w/pi, 20*log10(abs(h)));grid;
xlabel('\omega/\pi');ylabel('Gain, in dB');
Not for sale 362
title('Lowpass filter designed using Hann window');
axis([0 1 -80 10]);

% Blackman
M = ceil(5.56*pi/dw);N = 2*M+1;n = -M:M;
num = (6/18)*sinc(6*n/18);
wh = blackman(N)';b = num.*wh;

figure(5);
k=0:2*M:stem(k,b);
title('Impulse Response Coefficients');
xlabel('Time index n'); ylabel('Amplitude');
figure(6);
[h, w] = freqz(b,1,512);
plot(w/pi, 20*log10(abs(h)));grid;
xlabel('\omega/\pi');ylabel('Gain, in dB');
title('Lowpass filter designed using Blackman window');
axis([0 1 -80 10]);

Lowpass filter design using Hamming window: N = 31

0 5 10 15 20 25 30
-0.1
0
0.1
0.2
0.3
0.4
Impulse Response Coefficients
Time index n
A
m
p
l
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

i
n

d
B
Lowpass filter designed using Hamming window

Lowpass filter design using Hann window: N = 29

0 5 10 15 20 25
-0.1
0
0.1
0.2
0.3
0.4
Impulse Response Coefficients
Time index n
M
a
g
n
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

i
n

d
B
Lowpass filter designed using Hann window

Lowpass filter design using Blackman window: N = 53
Not for sale 363
0 10 20 30 40 50
-0.1
0
0.1
0.2
0.3
Impulse Response Coefficients
Time index n
M
a
g
n
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

i
n

d
B
Lowpass filter designed using Blackman window

Comments: The Hann window method results in using the lowest filter order. All filters
meet the requirements of the specifications.

M10.9 , 42 =
s
( ) ( ) 631 . 3 21 42 07886 . 0 21 42 5842 . 0
4 . 0
= + = using Eq. (10.41).

=
18
2
285 . 2
8 42

N using Eq. (10.42).

N = 42.627 43 and we choose 44 since N must be even. M = 22.
% Problem #M10.9
beta = 3.631;N = 44;n = -N/2:N/2;
num = (6/18)*sinc(6*n/18);
wh = kaiser(N+1,beta)';b = num.*wh;
figure(1);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('Amplitude')
figure(2);
[h, w] = freqz(b,1,512);
plot(w/pi, 20*log10(abs(h)));grid;
xlabel('\omega/\pi');ylabel('Gain, in dB');
title('Lowpass filter designed using Kaiser window');
axis([0 1 -80 10]);

0 10 20 30 40
-0.1
0
0.1
0.2
0.3
0.4
Impulse Response Coefficients
Time index n
A
m
p
l
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

i
n

d
B
Lowpass filter designed using Kaiser window

Not for sale 364

M10.10 , 4 . 0 =
p
6 . 0 =
s
, 42 =
s
dB, 5 . 0 =
c
, 2 . 0 =
We will use the Hann window since it meets the requirements and has the lowest order
from Table 10.2.
. 32 16 55 . 15
11 . 3
= = = N M

% Problem M10.10
n = -16:16;
lp = 0.5*sinc(0.5*n);wh = hanning(33);
b = lp.*wh';
figure(1);
k=0:2*n;stem(k,b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel(Amplitude');
figure(2);
[h, w] = freqz(b,1,512);
plot(w/pi, 20*log10(abs(h)));grid;
xlabel('\omega/\pi');ylabel('Gain, in dB');
title('Lowpass filter designed using Hann window');
axis([0 1 -80 10]);
0 5 10 15 20 25 30
-0.1
0
0.1
0.2
0.3
0.4
0.5
Impulse Response Coefficients
Time index n
A
m
p
l
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

i
n

d
B
Lowpass filter designed using Hann window

M10.11 We use the same specifications from Problem M10.10, but we use the Dolph-Chebyshev
window.
( )
( )
7 48
2 0 285 2
4 16 42 056 2
.
. .
. .
=

= N . We use N = 50, which is a much higher order

than in Problem M10.10.
%Pr obl emM10. 11
n = - 25: 25;
l p = 0. 5*si nc( 0. 5*n) ; wh = chebwi n( 51, 42) ;
b = l p. *wh' ;
f i gur e( 1) ;
st em( b) ;
t i t l e( ' I mpul se Response Coef f i ci ent s' ) ;
xl abel ( ' Ti me i ndex n' ) ; yl abel ( ' Ampl i t ude' ) ;
f i gur e( 2) ;
[ h, w] = f r eqz( b, 1, 512) ;
Not for sale 365
pl ot ( w/ pi , 20*l og10( abs( h) ) ) ; gr i d;
xl abel ( ' \ omega/ \ pi ' ) ; yl abel ( ' Magni t ude' ) ;
t i t l e( ' Fi l t er desi gned usi ng Dol ph- Chebyshev wi ndow' ) ;
axi s( [ 0 1 - 80 10] ) ;
0 10 20 30 40 50
-0.2
0
0.2
0.4
0.6
Impulse Response Coefficients
Time index n
A
m
p
l
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
M
a
g
n
i
t
u
d
e
Filter designed using Dolph-Chebyshev window

M10.12 n = -16:16;
b = fir1(32, 0.5, hanning(33));
figure(1);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel(' Ampl i t ude' );
figure(2);
[h, w] = freqz(b,1,512);
plot(w/pi, 20*log10(abs(h)));
grid;
xlabel('\omega/\pi');ylabel('Magnitude');
title(' Lowpass filter designed using Hann window');
axis([0 1 -80 10]);
0 5 10 15 20 25 30
-0.2
0
0.2
0.4
0.6
Impulse Response Coefficients
Time index n
A
m
p
l
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
M
a
g
n
i
t
u
d
e
Lowpass filter designed using Hann window

M10.13 N = 35;
f or k = 1: N+1,
w( k) = 2*pi *( k- 1) / ( N+1) ;
i f ( w( k) >= 0. 45*pi & w( k) <= 1. 45*pi ) H( k) = 1;
el se H( k) = 0;
end
i f ( w( k) <= pi ) phase( k) = i *exp( - i *w( k) *N/ 2) ;
el se phase( k) = - i *exp( i *( 2*pi - w( k) ) *N/ 2) ;
Not for sale 366
end
end
H = H. *phase;
f = i f f t ( H) ;
[ FF, w] = f r eqz( f , 1, 512) ;
k = 0: N;
f i gur e( 1) ;
st em( k, r eal ( f ) ) ;
xl abel ( ' Ti me i ndex n' ) ; yl abel ( ' Ampl i t ude' ) ;
f i gur e( 2) ;
pl ot ( w/ pi , 20*l og10( abs( FF) ) ) ; gr i d
xl abel ( ' \ omega/ \ pi ' ) ; yl abel ( ' Gai n, dB' ) ;
axi s( [ 0 1 - 50 5] ) ;
0 5 10 15 20 25 30 35
-0.5
0
0.5
Time index n
A
m
p
l
i
t
u
d
e

0 0.2 0.4 0.6 0.8 1
-50
-40
-30
-20
-10
0
/
G
a
i
n
,

d
B

M10.14 N = 45;
L = N + 1;
for k = 1:L,
w = 2*pi*(k-1)/L;
if (w >= 0.5*pi & w <= 0.7*pi) H(k) = i*exp(-i*w*N/2);
elseif (w >= 1.3*pi & w <= 1.5*pi) H(k) = -
i*exp(i*(2*pi-w)*N/2);
else H(k) = 0;
end
end
f = ifft(H);
[FF, w] = freqz(f, 1, 512);
k = 0:N;
figure(1);
stem(k, real(f));
xlabel('Time index, n');ylabel('h[n]');
figure(2);
plot(w/pi, 20*log10(abs(FF)));grid;
ylabel('Gain, dB');xlabel('\omega/\pi');
axis([0 1 -50 5]);
Not for sale 367
0 10 20 30 40
-0.2
-0.1
0
0.1
0.2
Time index, n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-50
-40
-30
-20
-10
0
G
a
i
n
,

d
B
/

M10.15 ind = 1;
for k = 0:6,
H(ind) = exp(-i*2*pi*19*k/39);
ind = ind + 1;
end
k = 7;
H(ind) = 0.5*exp(-i*2*pi*19*k/39);
ind = ind + 1;
for k = 8:30,
H(ind) = 0;
ind = ind + 1;
end
k = 31;
H(ind) = 0.5*exp(-i*2*pi*19*k/39);
ind = ind + 1;
for k = 32:38,
H(ind) = exp(-i*2*pi*19*k/39);
ind = ind + 1;
end
h = ifft(H);
[FF, w] = freqz(h, 1, 512);
plot(w/pi, 20*log10(abs(FF)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
axis([0 1 -50 5]);
0 0.2 0.4 0.6 0.8 1
-50
-40
-30
-20
-10
0
/
G
a
i
n
,

d
B

M10.16 ind = 1;
Not for sale 368
for k = 0:6,
H(ind) = exp(-i*2*pi*19*k/39);
ind = ind + 1;
end
k = 7;
H(ind) = (2/3)*exp(-i*2*pi*19*k/39);
ind = ind + 1;
k = 8;
H(ind) = (1/3)*exp(-i*2*pi*19*k/39);
ind = ind + 1;
for k = 9:29,
H(ind) = 0;
ind = ind + 1;
end
k = 30;
H(ind) = (1/3)*exp(-i*2*pi*19*k/39);
ind = ind + 1;
k = 31;
H(ind) = (2/3)*exp(-i*2*pi*19*k/39);
ind = ind + 1;
for k = 32:38,
H(ind) = exp(-i*2*pi*19*k/39);
ind = ind + 1;
end
h = ifft(H);
[FF, w] = freqz(h, 1, 512);
plot(w/pi, 20*log10(abs(FF)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
axis([0 1 -50 5]);
0 0.2 0.4 0.6 0.8 1
-50
-40
-30
-20
-10
0
/
G
a
i
n
,

d
B

M10.17
18
8
=
p
,
18
12
=
s
,
18
10
=
c
,
18
4
=
wp = 4*(2*pi)/18;
ws = 6*(2*pi)/18;
wc = (wp + ws)/2;
dw = ws - wp;
% Hamming
M = ceil(3.32*pi/dw);
N = 2*M;
b = fir1(N, ws/(2*pi));
Not for sale 369
[H, w] = freqz(b,1,512);
figure(1);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(2);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Lowpass filter designed using Hamming window');
axis([0 1 -80 10]);

% Hann
M = ceil(3.11*pi/dw);
N = 2*M;
b = fir1(N, ws/(2*pi), hanning(N+1));
[H, w] = freqz(b,1,512);
figure(3);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(4);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Lowpass filter designed using Hann window');
axis([0 1 -80 10]);

% Blackman
M = ceil(5.56*pi/dw);
N = 2*M;
b = fir1(N, ws/(2*pi), blackman(N+1));
[H, w] = freqz(b,1,512);

figure(5);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(6);
plot(w/pi, 20*log10(abs(H)));
grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Lowpass filter designed using Blackman window');
axis([0 1 -80 10]);

% Kaiser
beta = 3.631;
N = 44;
b = fir1(N, ws/(2*pi), kaiser(N+1, beta));
[H, w] = freqz(b,1,512);
figure(7);
stem(b);
title('Impulse Response Coefficients');
Not for sale 370
xlabel('Time index n');ylabel('h[n]');
figure(8);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Lowpass filter designed using Kaiser window');
axis([0 1 -80 10]);

(a) Hamming window using fir1
0 5 10 15 20 25 30
-0.1
0
0.1
0.2
0.3
0.4
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Lowpass filter designed using Hamming window

(b) Hann window using fir1
0 5 10 15 20 25
-0.1
0
0.1
0.2
0.3
0.4
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Lowpass filter designed using Hann window

(c) Blackman window using fir1
0 10 20 30 40 50
-0.1
0
0.1
0.2
0.3
0.4
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Lowpass filter designed using Blackman window

(d) Kaiser window using fir1
Not for sale 371
0 10 20 30 40
-0.1
0
0.1
0.2
0.3
0.4
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Lowpass filter designed using Kaiser window

M10.18 , , = 4 0.
s
= 55 0.
p
1 0. =
p
dB, 42 =
s
dB, = 15 0. , = 475 0.
c

(a) Hamming: use Eq. (10.33): 46 2 23 133 22
15 0
32 3
= = =

= M N M .
.
.

(b) Hann: 42 2 21 733 20
15 0
11 3
= = =

= M N M .
.
.

(c) Blackman: 76 2 38 067 37
15 0
56 5
= = =

= M N M .
.
.

(d) Kaiser: 00794 0 10
20
.
/
= =

s
s
% Hamming
N = 46;
b = fir1(N, 0.475, 'high');
[H,w] = freqz(b,1,512);
figure(1);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(2);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Highpass filter designed using Hamming window');
axis([0 1 -80 10]);

% Hann
N = 42;
b = fir1(N, 0.475, 'high', hanning(N+1));
[H,w] = freqz(b,1,512);
figure(3);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(4);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Highpass filter designed using Hann window');
axis([0 1 -80 10]);
Not for sale 372

% Blackman
N = 76;
b = fir1(N, 0.475, 'high', blackman(N+1));
[H,w] = freqz(b,1,512);
figure(5);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');

figure(6);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Highpass filter designed using Blackman window');
axis([0 1 -80 10]);

% Kaiser
ds = 0.00794;
[N,Wn,beta,type] = kaiserord([0.4 0.55],[1 0],[ds ds]);
b = fir1(N, 0.475,'high',kaiser(N+1,beta));
[H,w] = freqz(b,1,512);

figure(7);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(8);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Highpass filter designed using Kaiser window');
axis([0 1 -80 10]);

(a) Hamming window using fir1
0 10 20 30 40
-0.4
-0.2
0
0.2
0.4
0.6
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Highpass filter designed using Hamming window

(b) Hann window using fir1
Not for sale 373
0 10 20 30 40
-0.4
-0.2
0
0.2
0.4
0.6
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Highpass filter designed using Hann window

(c) Blackman window using fir1
0 20 40 60
-0.4
-0.2
0
0.2
0.4
0.6
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Highpass filter designed using Blackman window

(d) Kaiser window using fir 1
0 5 10 15 20 25 30
-0.4
-0.2
0
0.2
0.4
0.6
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Highpass filter designed using Kaiser window

M10.19 , , 65 . 0
1
=
p
85 . 0
2
=
p
55 . 0
1
=
s
, 75 . 0
2
=
s
, 2 . 0 =
p
dB, dB 42 =
s

1 . 0
1 1 1
= =
s p
, = = = 1 . 0
2 2 2 s p

(a) Hamming window: 68 2 34 2 . 33
1 . 0
32 . 3
= = = = M N M

(b) Hann: 64 2 32 1 . 31
1 . 0
11 . 3
= = = = M N M

Not for sale 374
(c) Blackman: 112 2 56 6 . 55
1 . 0
56 . 5
= = = = M N M

(d) Kaiser: , 00794 . 0 10
20 /
= =

s
s

97724 . 0 10
20 /
= =

p
p

% Problem #M10.19
% Hamming
N = 68;
b = fir1(N, [0.6 0.8]);
[H, w] = freqz(b,1,512);
figure(1);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(2);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Bandpass filter designed using Hamming window');
axis([0 1 -80 10]);

% Hann
N = 64;
b = fir1(N, [0.6 0.8], hanning(N+1));
[H, w] = freqz(b,1,512);
figure(3);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(4);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Bandpass filter designed using Hann window');
axis([0 1 -80 10]);

% Blackman
N = 112;
b = fir1(N, [0.6 0.8], blackman(N+1));
[H, w] = freqz(b,1,512);
figure(5);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');
figure(6);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Bandpass filter designed using Blackman window');
axis([0 1 -80 10]);

% Kaiser
[N, Wn, beta, type] = kaiserord([0.6 0.8], [1 0], [0.97724
0.00794]);
Not for sale 375
b = fir1(2*N, [0.6 0.8], kaiser(2*N+1, beta));
[H, w] = freqz(b,1,512);
figure(7);
stem(b);
title('Impulse Response Coefficients');
xlabel('Time index n');ylabel('h[n]');

figure(8);
plot(w/pi, 20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Bandpass filter designed using Kaiser window');
axis([0 1 -80 10]);

(a) Hamming window using fir1

0 10 20 30 40 50 60
-0.2
-0.1
0
0.1
0.2
0.3
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Bandpass filter designed using Hamming window

(b) Hann window using fir1
0 10 20 30 40 50 60
-0.2
-0.1
0
0.1
0.2
0.3
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Bandpass filter designed using Hann window

(c) Blackman window using fir1
Not for sale 376
0 20 40 60 80 100
-0.2
-0.1
0
0.1
0.2
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Bandpass filter designed using Blackman window

(d) Kaiser window using fir1
0 10 20 30 40
-0.2
-0.1
0
0.1
0.2
0.3
Impulse Response Coefficients
Time index n
h
[
n
]

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Bandpass filter designed using Kaiser window

M10.20

4286 . 0
70
15 2
=

=
c

% Problem #M10.20
N = 31;
d1 = fir1(N-1,0.4286);d2 = fir1(N-1,0.4286,'high');
[h1,w] = freqz(d1,1,512);h2 = freqz(d2,1,w);
plot(w/pi,20*log10(abs(h1)),'-r',w/pi,20*log10(abs(h2)),'--
b');grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Crossover pair');
axis([0 1 -80 10]);
0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Crossover pair

Not for sale 377

M10.21 , 2494 . 0
1
=
c
5442 . 0
2
=
c

% Problem #M10.21
N = 32;
d1 = fir1(N, 0.2494, hanning(33));
d2 = fir1(N, 0.5442, 'high', hanning(33));
d3 = -d1-d2;
d3(17) = 1-d1(17)-d2(17);
[h1,w] = freqz(d1,1,512);h2 = freqz(d2,1,w);h3 =
freqz(d3,1,w);
g1 = 20*log10(abs(h1))); g2 = 20*log10(abs(h2)));
g3 = 20*log10(abs(h3)));
plot(w/pi, g1,-b,w/pi,g2,-.g,w/pi,g3,-r);grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Crossover triple');
axis([0 1 -80 10]);
0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
Crossover triple

M10.22 % Problem #M10.22
fpts = [0 0.35 0.4 0.7 0.72 1];
mval = [0.2 0.2 1 1 0.6 0.6];
b = fir2(70, fpts, mval);
[H,w] = freqz(b,1,512);
figure(1);
plot(w/pi,abs(H));grid;
xlabel('\omega/\pi');ylabel('Magnitude');
title('Multilevel FIR filter');
axis([0 1 0 1.2]);
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e
Multilevel FIR filter

Not for sale 378

M10.23 From Problem 10.36,
= 45 0.
p
, , = 6 0.
s
2043 0. =
p
, 0454 0. =
s
and we assume that
. 2 =
T
F Therefore, 45 0
2
45 0
.
.
=

=
T
p
F
F and . .6 0 =
s
F
( ) 985 1 1 20
10
. log = =
p p
dB, ( ) 858 26 20
10
. log = =
s s
dB.
After obtaining the length N using remezord, the specifications of the filter were not
met. We increased N to 11 to meet the specifications.
% Program #M10.23
Ft = 2;Fp = 0.45;Fs = 0.6;
ds = 0.0454;dp = 0.2043;
F = [Fp Fs];A = [1 0];DEV = [dp ds];
[N,Fo,Ao,W] = remezord(F,A,DEV,Ft);
b = remez(N,Fo,Ao,W);
[H,w] = freqz(b,1,512);
figure(1);
plot(w/pi, 20*log10(abs(H)));
xlabel('\omega/\pi');ylabel('Gain, dB');title('N = 9');
%axis([0 0.45 -3 3]);
N = 11;
b = remez(N,Fo, Ao, W);
[H,w] = freqz(b,1,512);
figure(2);
plot(w/pi, 20*log10(abs(H)));
xlabel('\omega/\pi');ylabel(Gain, dB);title('N = 11');

Using remezord, we get N = 9. The corresponding gain response is shown in Figure (e)
below:
0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
20
/
G
a
i
n
,

d
B
N = 9

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
20
/
G
a
i
n
,

d
B
N = 11

(e) (f)

However, specifications are not met in the passband with this filter, so we increase N to
11. The corresponding gain response is shown in Figure (f) above. The specifications
are now met.
Not for sale 379

M10.24 From problem 10.37,
= 7 0.
p
, , = 55 0.
s
03808 0. =
p
, 0112 0. =
s
and we assume that
. 2 =
T
F Therefore, 7 0
2
7 0
.
.
=

=
T
p
F
F and . .55 0 =
s
F
( ) 3372 0 1 20
10
. log = =
p p
dB, ( ) 016 39 20
10
. log = =
s s
dB.
Using remezord, we get an estimate of N = 20. However, using this order, the
specifications are not met in the stopband, so we need to increase N up to 23 to meet the
specifications.
% Program #M10.24
Ft = 2;Fp = 0.7;Fs = 0.55;
ds = 0.0112;dp = 0.03808;
F = [Fs Fp];A = [0 1];DEV = [ds dp];
[N,Fo,Ao,W] = remezord(F,A,DEV,Ft);
b = remez(N,Fo,Ao,W);
[H,w] = freqz(b,1,512);
figure(1);
plot(w/pi, 20*log10(abs(H)));
xlabel('\omega/\pi');ylabel('Gain, dB');title('N = 20');
N = 23;
b = remez(N,Fo,Ao,W);
[H,w] = freqz(b,1,512);
figure(2);
plot(w/pi,20*log10(abs(H)));
xlabel('\omega/\pi');ylabel('Gain,dB ');title('N = 23');

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
N = 20

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
N = 24

Note: As odd order symmetric FIR filters must have a gain of zero at the Nyquist
frequency. The order has been increased by one by remez.

M10.25 From Problem 10.38,
= 55 0
1
.
p
, , = 7 0
2
.
p
= 44 0
1
.
s
, = 82 0
2
.
s
, 01 0. =
p
, ,
.
007 0
1
. =
s
002 0
2
. =
s
( ) 087 0 1 20
10
. log = =
p p
dB,
Not for sale 380
( ) 43 20
1 10 1
= =
s s
log dB, ( ) 54 20
2 10 2
= =
s s
log dB.

% Program #M10.25
Ft = 2;Fp1 = 0.55;Fp2 = 0.7;Fs1 = 0.44;Fs2 = 0.82;
ds1 = 0.007;ds2 = 0.002;dp = 0.01;
F = [Fs1 Fp1 Fp2 Fs2];A = [0 1 0];DEV = [ds1 dp ds2];
[N,Fo,Ao,W] = remezord(F,A,DEV,Ft);
b = remez(N,Fo,Ao,W);
[H, w] = freqz(b, 1, 512);
figure(1);
plot(w/pi,20*log10(abs(H)));grid;
xlabel('\omega/\pi');ylabel('Gain, dB');title('N = 39');
axis([0 1 -80 10]);

N = 41;
b = remez(N, Fo, Ao, W);
[H, w] = freqz(b, 1, 512);
figure(2);
plot(w/pi, 20*log10(abs(H)));
xlabel('\omega/\pi');ylabel('Gain, dB');title('N = 41');
axis([0 1 -80 10]);

Using remezord, we estimate the filter length to be N = 39. However, the minimum
stopband attenuation specifications are not met in both stopbands, so we increase N to 41
0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
N = 39

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B
N = 41

.

M10.26 % Program #M10.26
b = remez(29, [0 1], [0 pi], 'differentiator');
[H, w] = freqz(b, 1, 512);
plot(w/pi,abs(H));grid
xlabel('\omega/\pi');ylabel('Magnitude');
axis([0 1 0 pi]);

The magnitude response of the differentiator is given below:
Not for sale 381
0 0.2 0.4 0.6 0.8 1
0
0.5
1
1.5
2
2.5
3
/
M
a
g
n
i
t
u
d
e

M10.27 % Program #M10.27
f = [0.02 0.05 0.07 0.95 0.97 1];
m = [0 0 1 1 0 0];
wt = [1 60 1];
b = remez(30, f, m, wt, 'hilbert');
[H,w] = freqz(b,1,512);
plot(w/pi,abs(H));grid
xlabel('\omega/\pi');ylabel('Magnitude');
axis([0 1 0 1.2]);

The magnitude response of the Hilbert transformer is shown below:
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
/
M
a
g
n
i
t
u
d
e

M10.28 , , = 35 0.
p
= 5 0.
s
1 =
p
R dB, and 28 =
s
R dB.
% Program #M10_28
% Design of a minimum-phase lowpass FIR filter
Wp = 0.35; Ws = 0.5; Rp = 1; Rs = 28;
% Desired ripple values of minimum-phase filter
dp = 1- 10^(-Rp/20); ds = 10^(-Rs/20);
% Compute ripple values of prototype linear-phase filter
Ds = (ds*ds)/(2 - ds*ds);
Dp = (1 + Ds)*((dp + 1)*(dp + 1) - 1);
% Estimate filter order
[N,fpts,mag,wt] = remezord([Wp Ws], [1 0], [Dp Ds]);
% Design the prototype linear-phase filter H(z)
[b,err,res] = remez(N,fpts,mag,wt);
K = N/2;
b1 = b(1:K);
Not for sale 382
% Design the linear-phase filter G(z)
lenerr= res.error(length(res.error));
c = [b1 (b(K+1) + lenerr)) fliplr(b1)]/(1+Ds);
zplane(c);title('Zeros of G(z)');pause
c1 = c(K+1:N+1);
[y, ssp, iter] = minphase(c1);
zplane(y);title(Zeros of the minimum-phase filter);
pause
[hh,w] = freqz(y,1, 512);
% Plot the gain response of the minimum-phase filter
plot(w/pi, 20*log10(abs(hh)));grid
xlabel('\omega/\pi');ylabel('Gain, dB');
-6 -4 -2 0
-2
-1
0
1
2
2 20
Real Part
I
m
a
g
i
n
a
r
y

P
a
r
t
Zeros of G(z)

-1.5 -1 -0.5 0 0.5 1 1.5
-1
-0.5
0
0.5
1
10
Real Part
I
m
a
g
i
n
a
r
y

P
a
r
t
Zeros of the minimum-phase filter

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
20
/
G
a
i
n
,

d
B

M10.29 % Program #M10.29
c = [2.4 6.76 26.15 68.43 186.83 326.51 565.53 678.95 805.24
678.95 565.53 326.51 186.83 68.43 26.15 6.76 2.4];
h = firminphase(c)

The coefficients of the minimum phase spectral factor are:
h = 7.6730 8.5329 18.0722 12.5696 12.6822 4.8388 2.0784 0.5332 0.3128

M10.30 % Program #M10.30
[h,g]=ifir(6,'low',[.1 .15],[.001 .001]);
[hh,w]=freqz(h,1,1024); hg=freqz(g,1,1024);
h = hh.*hg; % Compounded response
Fg = 20*log10(abs(hh)); Ig = 20*log10(abs(hg));
plot(w/pi,Fg,'-r',w/pi,Ig,'--b'); grid;
axis([0 1 -90 5]);
Not for sale 383
legend('F(z^6)','I(z)');
xlabel('\omega/\pi');title('Gain responses, in dB');
pause;
plot(w/pi,20*log10(abs(h))); grid;
axis([0 1 -90 5]);
xlabel('\omega/\pi');title('Gain response, in dB');
gtext('H_{IFIR}(z)');
0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
Gain responses, in dB
F(z
6
)
I(z)

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
Gain response, in dB
H
IFIR
(z)

M10.31 % Program #M10.31
[h,g]=ifir(6,'high',[.9 .95],[.002 .004]);
[hh,w]=freqz(h,1,1024); hg=freqz(g,1,1024);
h = hh.*hg; % Compounded response
Fg = 20*log10(abs(hh)); Ig = 20*log10(abs(hg));
plot(w/pi,Fg,'-r',w/pi,Ig,'--b'); grid;
axis([0 1 -90 5]);
legend('F(z^6)','I(z)');
xlabel('\omega/\pi');title('Gain responses, in dB');
pause;
plot(w/pi,20*log10(abs(h))); grid;
axis([0 1 -90 5]);
xlabel('\omega/\pi');title('Gain response, in dB');
gtext('H_{IFIR}(z)');

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
Gain responses, in dB
F(z
6
)
I(z)

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
Gain response, in dB
H
IFIR
(z)

Not for sale 384

M10.32 % Problem #M10.32
InpN = ceil(2*pi/(0.15*pi));

% Plotting function
% plots the result of using an equalizer of length InpN
%function [N] = plotfunc(InpN);
% Creating filters
Wfilt = ones(1, InpN);
Efilt = remezfunc(InpN, Wfilt);

% Plot running sum filter response
figure(1);
Wfilt = Wfilt/sum(Wfilt);
[hh, w] = freqz(Wfilt, 1, 512);
plot(w/pi, 20*log10(abs(hh)));
axis([0 1 -50 5]);grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Prefilter H(z)');

% Plot equalizer filter response
figure(2);
[hw, w] = freqz(Efilt, 1, 512);
plot(w/pi, 20*log10(abs(hw)));
axis([0 1 -50 5]);grid;
xlabel('\omega/\pi');ylabel('Gain, dB');
title('Equalizer F(z)');

figure(3);
Cfilt = conv(Wfilt, Efilt);
[hc, w] = freqz(Cfilt, 1, 512);
plot(w/pi, 20*log10(abs(hc)));
axis([0 1 -80 5]);grid;
xlabel('\omega/\pi');ylabel('Gain, dB');

% Remez function using 1/P(z) as desired amplitude
% and P(z) as weighting
function [N] = remezfunc(Nin, Wfilt);
% Nin : number of tuples in the remez equalizer filter
% Wfilt : the prefilter
a = [0:0.001:0.999]; % The accuracy of the computation
w = a.*pi;wp = 0.05*pi;ws = 0.15*pi;
i = 1;n = 1;
for t = 1:(length(a)/2),
Not for sale 385
if w(2*t) < wp
pas(i) = w(2*t - 1);
pas(i+1) = w(2*t);
i = i+2;
end
if w(2*t-1) > ws
sto(n) = w(2*t - 1);
sto(n+1) = w(2*t);
n = n+2;
end
end
w = cat(2, pas, sto);
bi = length(w)/2;
for t1 = 1:bi,
bw(t1) = (w(2*t1) + w(2*t1-1))/2;
W(t1) = Weight(bw(t1), Wfilt, ws);
end
W = W/max(W);
for t2 = 1:length(w),
G(t2) = Hdr(w(t2), Wfilt, wp);
end
G = G/max(G);
N = remez(Nin, w/pi, G, W);

% Weighting function
function[Wout] = Weight(w, Wfilt, ws);
K = 22.8;
L = length(Wfilt);
Wtemp = 0;
Wsum = 0;
for k = 1:L,
Wtemp = Wfilt(k)*exp((k-1)*i*w);
Wsum = Wsum + Wtemp;
end
Wout = abs(Wsum);
if w > ws,
Wout = K*max(Wout);
end

% Desired function
function [Wout] = Hdr(w, Wfilt, ws);
if w <= ws,
L = length(Wfilt);
Wtemp = 0;
Wsum = 0;
for k = 1:L,
Wtemp = Wfilt(k)*exp(i*(k-1)*w);
Wsum = Wsum + Wtemp;
end
Wsum = abs(Wsum);
Wout = 1/Wsum;
Not for sale 386
else
Wout = 0;
end

0 0.2 0.4 0.6 0.8 1
-50
-40
-30
-20
-10
0
/
G
a
i
n
,

d
B
Prefilter H(z)

0 0.2 0.4 0.6 0.8 1
-50
-40
-30
-20
-10
0
/
G
a
i
n
,

d
B
Equalizer F(z)

0 0.2 0.4 0.6 0.8 1
-80
-60
-40
-20
0
/
G
a
i
n
,

d
B