- QQ：99515681
- 郵箱：[email protected]
- 工作時間：8:00-23:00
- 微信：codinghelp

Department of Electrical and Electronic Engineering

ELEC6026/ELEC8004 Digital Signal Processing

Assignment: Design of Linear Phase FIR Filters

(15 marks)

1. Objectives:

The purpose of this assignment is to study the properties of Short Time Fourier Transform

(STFT) based spectral analysis and the design of one dimensional finite-duration impulse

response (FIR) linear phase filters using MATLAB. The window method, parks-McClellan

method and convex programming method will be studied.

2. Equipment Required

MATLAB: MATLAB is an interactive environment for high level simulation of general

numerical applications such as numerical linear algebra, signal processing, etc. Refer to

http://www.mathworks.com/help/matlab/ for more details.

If you do not have the MATLAB software, you may use the PC workstations located at the

CYC103 Laboratory.

Reference: A.V. Oppenheim, Discrete-time Signal Processing, Prentice-Hall, 1991.

3. Submission Format and Deadline

A brief written report addressing the problems listed in section 5 should be submitted either in

Microsoft Word or PDF format together with the appended MATLAB codes and uploaded to

the Moodle System by Nov 20, 2019 23:55 (GMT +8:00).

4. Theory

4.1 Window method

Window method generally begins with an ideal frequency response:

is the corresponding impulse response sequence. Many idealized systems are

defined by piecewise-constant or piecewise-functional frequency responses with discontinuities

at the boundaries between bands. As a result, they have impulse response that are noncausal and

infinitely long. Window method truncates the infinitely long impulse response by multiplying it

with a finite sequence called the window functions:

h(n) h (n) (n) ? d ? (2)

The Fourier transform of the FIR filter is then given by:

(3)

which is the periodic convolution of the desired ideal frequency response with the Fourier

transform of the windows. Hence, ( )

j? H e will be a smeared version of ( )

j?

d H e . The most

popular window functions being the Kaiser window:

(4)

where ? ? M / 2 , and 0

I represents the zeroth-order modified Bessel function of the first kind.

The design procedure involves the determination of the order M and the shape parameter ?

from the given specification. Let

min{ , } ? ? ? 1 ? 2

?? ? ?s ?? p

(for lowpass approximation)

where 1 2 ? ,? are respectively the pass and stop band ripples in the specification.

?s ? p

, are respectively the stop and pass band edge frequencies.

Define

A? ?20log10 ? (5)

Kaiser determined empirically that the value of ? and M needed to meet the specification is

given by:

Similar procedure can be applied to design multiband filters.

4.2 Parks-McClellan method

The Parks-McClellan algorithm uses the Remez exchange algorithm and Chebyshev

approximation theory to design filters with optimal ? error norm, i.e. the maximum error

between the desired frequency response and the actual frequency response is minimized. Filter

designed in this way exhibit an equiripple behavior in their frequency response.

Unlike the Kaiser window method, the pass and stop band ripples need not be the same. Kaiser

has obtained the following simplified formula for the estimation of filter order for a given

specification:

4.3 Convex programming method

Optimization toolbox: The problem mentioned above can be solved using a free Matlab toolbox

“CVX”, which is available at

http://cvxr.com/cvx/download

Install the CVX toolbox according to the descriptions therein.

Background:

In FIR filter design, the following minimax problem is commonly encountered:

where h(n) is the filter coefficients to be determined, ? is the frequency interval of interest,

( )

j? H e is the frequency response of the FIR filter given by

is the ideal frequency response. Typical ideal frequency

responses of lowpass and highpass FIR filters are respectively given by

where ? is the group delay of the FIR filter, and ? p

and ?s

are the passband and stopband

edges, respectively.

4.4 PC-MATLAB

PC-MATLAB is an interactive environment for high level simulation of general numerical

applications such as numerical linear algebra, signal processing, etc.

MATLAB works with essentially only one kind of object, a rectangular numerical matrix with

possibly complex elements. Refer to PC-MATLAB Reference and Tutorial for more details of

matrix declaration and manipulation.

User defined function or command files can be added to MATLAB’s vocabulary if they are

expressed in terms of other existing functions. The commands and functions that comprise the

new function are put in a file whose name defines the name of the new function, with a file type

of .m appended. See the PC-MATLAB reference pp.3-84-3.85 for details. M-files can be created

using ordinary text-editor and placed in the same directory of MATLAB or other defined search

path in MATLAB. Type the name of the M-file in MATLAB environment will invoke the

commands or functions defined in the corresponding M-file.

In this experiment, we shall make use of two functions in the Signal Processing Toolbox in the

PC-MATLAB for designing linear phase FIR filters.

fir1 implements the classical method of windowed linear-phase FIR digital filter design. It is

formulated to design filters in standard lowpass, bandpass, highpass and bandstop configurations.

For example

b=fir1(n,Wn,kaiser(n+1,β))

Returns row vector b containing the n+1 coefficients of the order n Kaiser windowed lowpass

linear-phase FIR filter with normalized cutoff frequency Wn. Refer to MATLAB Signal

Processing Toolbox Tutorial pp. 1-32 - 1-33 and 2-61 - 2-62 for more details.

remez is a function to design linear phase FIR filters using the Parks-McClellan algorithm.

b=remez(n,f,m,w)

returns row vector b containing the n+1 coefficients of the order n FIR filter whose frequencymagnitude

characteristics match those given by vector f and m. For later versions of the

MATLAB, the remez function is replaced by firpm. The usage of firpm is similar to that of the

remez function

b=firpm(n,f,m,w)

f is a vector of frequency points, specified in the range between 0 and 1, where 1.0 corresponds

to half the sample frequency.

m is a vector containing the desired magnitude response at the points specified in f. The elements

of m must appear in equal-valued pairs.

w is the weight used in each frequency band.

Refer to pp. 1-34 - 1-35 and 2-91 - 2-93 of the Signal Processing Toolbox tutorial or the online

help manual of the PC-MATLAB for more details.

5. Procedure

The assignment package ‘ass1.zip’ contains the following files:

? ass1_main.m: This script is used to calculate and display the spectrogram of the synthetic

signal which is stored in Signal.mat. The script will load a variable named ‘x’, which is

a signal. The total duration of the signal is 2 seconds and the sampling rate is 200 Hz.

? stft.m: In-house MATLAB scripts to perform STFT.

? fir_type2_hp_cvx.m: This script is to design a type-II FIR linear-phase highpass filter

with the ideal frequency response in (12) and the following specifications:

(a) N ? 31.

(b) ?s ? 0.6? and ?p ? 0.8? .

(c) ? ? (N ?1)/ 2 ?15 .

(d) Coefficient symmetry: h(n) ? h(N ?1? n) , n ? 0,1,...,N .

(i) Run ass1_main.m to display the synthetic signal and the STFT-based spectrogram

using the default setting (window length = 0.3s). From the signal and its spectrogram,

comment on the properties of the signal and identify the frequency of the signal at

t ? 0,1 and 2 s.

(1 marks)

(ii) Re-calculate the spectrogram using the in-house program stft with different window

sizes: 0.2 and 0.5. Modify the MATLAB code in ass1_main.m to plot the two

spectrograms. Describe the difference between these spectrograms. Discuss how the

window size affects the time and frequency resolutions of the spectrograms.

(2 marks)

(iii) Use the function fir1 in MATLAB to design an FIR lowpass filter using Kasier

Window method with the following specifications:

? ? 0.6?, p ? ? 0.7?, s 0.001, ? 1 ? and 0.01, ? 2 ? (13)

Obtain the estimate of the filter from eqn. (5) – (7).

(1 marks)

(iv) Use the Parks-McClellan method (function firpm in MATLAB) to design a lowpass

filter with the specification as in (13). Obtain the estimate of the filter from eqn. (8).

(1 marks)

(v) Plot and discuss the frequency response of filters designed in (iii) and (iv).

(1 marks)

(vi) Comment on the two approaches in designing linear phase FIR filters.

(2 marks)

(vii) Use the convex programming method (refer to fir_type2_hp_cvx.m) to design a

lowpass filter with the same passband and stopband as in (13). Maintain the same ratio

of ripples in passband and stopband as in (13). Use the same filter length as calculated

in (iv). Plot its impulse, group delay and frequency responses.

(2 marks)

(viii) (*)Use the filter designed in (vii) to filter signal ‘x’ by linear convolution.

(2 marks)

Remarks (*) You are not allowed to use the function conv in MATLAB for your

implementation. However, you may use it to verify the accuracy of your own code.

(ix) Calculate the spectrogram of filtered signal with default window size. Plot the filtered

signal and its spectrogram.

(1 marks)

(x) Comment and explain the difference between the spectrogram of signal ‘x’ and the

filtered signal.

(2 marks)

***END***

版權所有：編程輔導網 2018 All Rights Reserved 聯系方式：QQ:99515681 電子信箱：[email protected]

免責聲明：本站部分內容從網絡整理而來，只供參考！如有版權問題可聯系本站刪除。