0% found this document useful (0 votes)
37 views

Coursework 2023

The coursework for MHH623541 Digital Signal Processing involves writing a 3000-word laboratory report in Matlab detailing signal processing experiments. It is due on December 15th and must avoid plagiarism. The report will be graded on presentation (40%), experiment details (30%), and observations (30%). Matlab supports various FIR filter design methods including windowing. FIR filters have linear phase but require higher order than IIR filters for the same performance. Windowing approximates ideal filters and reduces truncation effects.

Uploaded by

bigbil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Coursework 2023

The coursework for MHH623541 Digital Signal Processing involves writing a 3000-word laboratory report in Matlab detailing signal processing experiments. It is due on December 15th and must avoid plagiarism. The report will be graded on presentation (40%), experiment details (30%), and observations (30%). Matlab supports various FIR filter design methods including windowing. FIR filters have linear phase but require higher order than IIR filters for the same performance. Windowing approximates ideal filters and reduces truncation effects.

Uploaded by

bigbil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

MHH623541 Digital Signal Processing

Coursework (30% of the module mark)


Coursework overview
The coursework should be written as a formal, up to 3000 words (not
counting references) laboratory report, detailing the experimental process
undertaken in Matlab, any required mathematics, and explanations on what
you observe. All questions within the text should be attempted.

Coursework marking weights are in brackets [%]

- Presentation of information, including writing, spelling, structure,


figures, equations, references. [ 40%]
- Details of Matlab experiments. [ 30%]
- Explanations of observations. [ 30%]

Due: 15/12/2023 (4 pm on Friday of Week 12)


Submit electronic copy on GCU Learn (no excuse for late submissions as the
coursework has been given out in Week 2)

Plagiarism
Please note the following School statement on Plagiarism: “The deliberate
and substantial unacknowledged incorporation in your submission of
material derived from work (published or unpublished) of another is
prohibited. In such cases the work submitted is classified as illegal and
will result in further action being taken by the University, which may include
recording a failure.”

Marking Criteria
All assessed work shall be marked according to the following performance criteria.
Description % Mark
Excellent 70+
Above Average 60-69
Average 50-59
Satisfactory 40-49
Unsatisfactory 0-39
The definition of the criteria named are:

G Morison & S Sinanovic page 1


MHH623541 Digital Signal Processing

Excellent Performance: All of the relevant information accurately presented. Outstanding


understanding of technical issues. Comprehensive number of sources of information used.
Exceptional presentation, structure and readability. Outstanding appreciation of current
applications. Relevant and complete conclusions included.
Above average performance: Most of the relevant information accurately presented. Good
grasp of technical issues. Good presentation, structure and readability. Good grasp of
current applications. Relevant and mostly complete conclusions included.
Average performance: Much of the relevant information accurately presented. Adequate
grasp of technical issues. Adequate presentation, structure and readability. Adequate grasp
of current applications. Relevant conclusions included.
Satisfactory performance: Some of the relevant information accurately presented.
Acceptable grasp of technical issues. Acceptable presentation, structure and readability.
Some understanding of of current applications. Brief conclusions included.
Unsatisfactory performance: Major deficiencies or omissions in the information presented.
Unacceptable grasp of technical issues. Evidence of very few sources of information
consulted. Poor presentation. Lack of understanding of the current applications. No
conclusions.

PART A: FIR Filtering (about 1500 words)

Overview and Goals


The goal of filtering is to perform frequency-dependent alteration of a signal. A simple design
specification for a filter might be to remove noise above a certain cutoff frequency. Within this
laboratory you will explore FIR within Matlab.

Digital filters with finite-duration impulse response (referred to as FIR filters) have both
advantages and disadvantages when compared to infinite-duration impulse response (IIR)
filters.

FIR filters have the following primary advantages:

• They can have exactly linear phase.


• They are always stable, even when quantized.
• The design methods are generally linear.
• They can be realized efficiently in hardware.
• The filter startup transients have finite duration.

The primary disadvantage of FIR filters is that they often require a much higher filter order
than IIR filters to achieve a given level of performance. Correspondingly, the delay of these
filters is often much greater than for an equal performance IIR filter.

FIR Methods

The Signal Processing Toolbox supports a variety of methods for the design of FIR filters.

G Morison & S Sinanovic page 2


MHH623541 Digital Signal Processing

Question 1: Using an appropriate search, list the methods available in Matlab for designing FIR
filters.

Impulse Response

FIR filters are described by difference equations of the form

𝑦𝑦(𝑛𝑛) = ∑𝑀𝑀
𝑚𝑚=0 𝑥𝑥(𝑚𝑚)ℎ(𝑛𝑛 − 𝑚𝑚) (1)

where the filtered signal y(n) is just a linear combination of current and previous values of
the input signal x(n). The coefficients b (b(m)) are the numerator coefficients of the transfer
function. The denominator of the transfer function will always be a = 1. The order of the
filter is n = length(b) -1.

Question 2: Explain how to calculate the impulse response of the above filter.

Try this in Matlab. Let b represent the coefficients of the x's in equation (1).

b = [-1 0 2 -3 1]; % no need to specify the a coefficients


stem(b)
figure, impz(b,1)

Linear Phase Filters


A filter whose impulse response is symmetric or antisymmetric about its midpoint is called
a (generalized) linear phase filter. That is,

ℎ(𝑛𝑛) ↔ 𝐻𝐻(𝑒𝑒 𝑗𝑗𝑗𝑗𝑗𝑗 ) = |𝐻𝐻�𝑒𝑒 𝑗𝑗𝑗𝑗𝑗𝑗 �|𝑒𝑒 𝑗𝑗𝑗𝑗(𝜔𝜔) (2)


with
𝜃𝜃(𝜔𝜔) = 𝐾𝐾𝐾𝐾 (3)

• The phase shift of the altered signal 𝜃𝜃(𝜔𝜔) will vary linearly with frequency 𝜔𝜔. (This translates
into the fact that the output signal of such a filter has a pure time delay with respect to the
input signal. There is no phase distortion).
• The phase delay −𝜃𝜃(𝜔𝜔)/𝜔𝜔 and the group delay −𝑑𝑑𝑑𝑑(𝜔𝜔)/𝑑𝑑𝑑𝑑 will be equal and constant

Except for cfirpm, all the FIR filter design functions in the Signal Processing Toolbox design linear
phase filters only.

Try this in Matlab

a = 1;
b = fir1(5,0.5);
fvtool(b,a)

This is the classic method of windowed FIR linear-phase filter design. Look at the phase delay and the
group delay in fvtool.

G Morison & S Sinanovic page 3


MHH623541 Digital Signal Processing

Question 3: Explain the functionality of the fir1 Matlab function.

Question 4: For this (5th order) 6-point filter, confirm that the phase 𝜃𝜃(𝜔𝜔) ≈ −2.5𝜔𝜔 as
seen in the phase plot of fvtool. Provide theoretical explanation for this finding.

FIR Filter Types


The symmetric impulse response of a linear phase filter can have an odd or an even number
of points, and can have an odd or even symmetry about the midpoint, leading to four filter
types:

• Type I: Odd length, even symmetry


• Type II: Even length, even symmetry
• Type III: Odd length, odd symmetry
• Type IV: Even length, odd symmetry

Question 5: Describe any restrictions that can occur when using each of the above types of FIR
filter. Hint: use Matlab help.

G Morison & S Sinanovic page 4


MHH623541 Digital Signal Processing

Window Based Design


Under FIR Methods above, Windowing is the first filter design method. It is the common,
classic design method for FIR filters.

Recall that the frequency response 𝐻𝐻�𝑒𝑒 𝑗𝑗𝑗𝑗𝑗𝑗 � is periodic. Hence it can be written as a Fourier series.
That is

𝐻𝐻(𝑒𝑒 𝑗𝑗𝑗𝑗𝑗𝑗 ) = ∑∞
𝑛𝑛=−∞ ℎ[𝑛𝑛]𝑒𝑒
−𝑗𝑗𝑗𝑗𝑗𝑗
(4)

ℎ[𝑛𝑛] are the Fourier coefficients that are determined using the inverse DTFT. In general, the
impulse response cannot be implemented as a digital filter because it is infinite and non-
causal.

Question 6: Show using the Inverse DTFT that the ideal frequency response of a low pass filter,
cannot be implemented, and explain why this is the case.

So, ℎ[𝑛𝑛] is symmetrically truncated (multiplied by a finite, symmetric window) and shifted
to make it causal, to create an implementation that gives a linear phase finite impulse response.

(Recall that from Fourier series properties, if the function is even, the Fourier coefficients
are even and if the function is odd, Fourier coefficients are odd. Hence for 𝐻𝐻(𝑒𝑒 𝑗𝑗𝑗𝑗𝑗𝑗 ) even, like
for a low pass filter, ℎ[𝑛𝑛] will be even, i.e. symmetric.)

The truncated Fourier series can be shown to be an approximation to the ideal filter, which
is “best" in a mean square sense, compared to other approximations of the same length.
However, the abrupt truncation leads to overshoot (Gibb's phenomenon) and ripples in the
spectrum. The undesirable effects of truncation can be reduced or eliminated by the use of
tapered windows.

Question 7: Describe what is meant by the Gibb’s phenomenon.

The Windowing method does not allow you to design a filter, with explicit amplitude response
constraints, such as passband ripple or stopband attenuation. It needs to be used iteratively and we
stop when design specifications are met.

Using the file windemo.m from GCU Learn, try the following in Matlab

edit windemo
windemo(20)
windemo(50)
windemo(100)

Question 8: What do the arguments (20, 50, 100) specify?

Question 9: How does the filter frequency response change with increasing the size of
the filter?

Question 10: Even as you increase the number of filter coefficients that you retain, does
the largest overshoot in the magnitude frequency response decrease in size?

G Morison & S Sinanovic page 5


MHH623541 Digital Signal Processing

Question 11: Explain what is happening in the 4 figures that you see in windemo.

Windowing Functions

In windemo you saw the effects (Gibbs phenomena) on the frequency response of the finite
length filter when a (default) rectangular window was imposed. Now we see methods of
ridding ourselves of Gibbs phenomena - at a price.

The Signal Processing Toolbox supports a variety of windows commonly used in FIR filter
design. (We will see this in class.) Typing

help window

provides a list of the available windows:

Individual window functions take inputs for a window length n and window parameters and
return the window w in a column vector of length n. (Note: Use w' for array products with
row vector impulse responses.) The window function serves as a gateway to the individual
functions.

alpha=0.25
w = gausswin(64,alpha)

and

w = window(@gausswin,64,alpha)

both return a Gaussian window of length 64 with standard deviation equal to 1/alpha.

Question 12: Pick two of the available windows and discuss and demonstrate their properties.

Windowing and Spectra

As we saw above, when a signal is truncated in time, high-frequency components are


introduced in frequency that are visible in the DFT spectrum. By windowing the truncated
signal in the time domain, endpoints are assigned a reduced weight. The effect of this on
the DFT is to reduce the height of the side lobes in the spectrum, but increase the width of
the main lobe. (That is the penalty we pay). Here is a simple demonstration:

Using the file windft.m from GCU Learn

Try this is Matlab

edit windft
windft

G Morison & S Sinanovic page 6


MHH623541 Digital Signal Processing

You see a truncated signal (5 Hz sine wave) and its DFT (Recall the Fourier transform of a
sine wave? Do you see how the DFT is different?) Then, the truncated sine wave is multiplied
by a Gaussian window and the DFT is taken of the truncated windowed signal.

Question 13: Detail and explain the output of the above function.

Question 14: For a continuous-time sine wave, its Fourier transform are a couple of delta functions.
For a discrete-time truncated sine wave, how is its spectrum (DFT) different to the idealized delta
function spectrum of a (continuous-time) sine wave?

Question 15: How does windowing the truncated sine wave "improve" the DFT spectrum?

Note: You have a 5 Hertz sine wave.

If you edit windft you see that you are just looking at it for 1 second. So you see 5 cycles of it in 1
second (Why?). Hence you are taking a sine wave, infinitely long, and putting a 1 second rectangular
window on it. In the analogue domain you have,

𝑥𝑥𝑤𝑤 (𝑡𝑡) = sin(2𝜋𝜋5𝑡𝑡) ∙ 𝑤𝑤𝑅𝑅 (𝑡𝑡) (5)

where 𝑤𝑤𝑅𝑅 (𝑡𝑡)is a 1 second rectangular window.

Question 16: Calculate the Fourier transform of the signal 𝑥𝑥𝑤𝑤 (𝑡𝑡).

Question 17: Compare the results of the Fourier transform with the Matlab output from the DFT of
the signal.

Window Visualisation Tool

To “window" a filter, the filter impulse response h(n) of size N is multiplied by a window
of size N. The transition bandwidth of a window-based FIR filter is determined, by the width of the
main lobe of the DFT of the window function. The main lobe width, as you can observe, can be
adjusted by changing size of N. Passband and stopband ripples are determined by the magnitude of
the side lobe of the DFT of the window function, and are usually not adjustable by changing the filter
order.

Ideally, the spectrum of a window should approximate an impulse. The main lobe should be
as narrow as possible and the side lobes should contain as little energy as possible.
The Window Visualization Tool (WVTool) allows you to investigate the tradeoffs among
different windows and filter orders.

wvtool(windowname(n))

opens WVTool with time and frequency domain plots of the n-length window specified in
windowname, which can be any window in the Signal Processing Toolbox. Several windows
can be given as input arguments for comparative display.

Try the following in Matlab

wvtool(hamming(64),hann(64),gausswin(64),rectwin(64))

G Morison & S Sinanovic page 7


MHH623541 Digital Signal Processing

wvtool(hamming(32),kaiser(32,2.5),flattopwin(32))
wvtool(kaiser(32,1),kaiser(32,5),kaiser(32,10))

Question 18: Comment on the differences - main lobe width and ripples - between the
same size rectangular window and the Hamming window.

Window Design and Analysis Tool

The Window Design and Analysis Tool (WinTool) is used in conjunction with the Window
Visualization Tool.

• Use WVTool for displaying and comparing existing windows created in the Matlab
workspace.
• Use WinTool to interactively design windows with certain specifications and export them
to the Matlab workspace.

Most window types satisfy some optimality criterion. Some windows are combinations of simpler
windows. For example, the Hann window is the sum of a rectangular and a cosine window, and the
Bartlett window is the convolution of two rectangular windows. Other windows emphasize certain
desirable features. The Hann window improves high-frequency decay (at the expense of larger peaks
in the side lobes). The Hamming window minimizes side lobe peaks (at the expense of slower high-
frequency decay). The Kaiser window has a parameter that can be tuned to control side lobe levels.
Other windows are based on simple mathematical formulas for easy application. The Hann window is
easy to use as a convolution in the frequency domain.

An optimal time-limited window maximizes energy in its spectrum over a given frequency band. In
the discrete domain, the Kaiser window gives the best approximation to such an optimal window.

Try

windowDesigner

Question 19: Experiment with different windows (minimum 3) and detail what you find.

The material in this lab derives somewhat from the MathWorks training document “MATLAB for
Signal Processing" by G. Morison and S. Sinanovic.

G Morison & S Sinanovic page 8


MHH623541 Digital Signal Processing

Part B: The Fast Fourier Transform (about 1500 words)


Overview and Goals
Since its development, the Fast Fourier Transform (FFT) algorithms have revolutionized the field of
signal processing. They allow the calculation of the Discrete Fourier Transform in real time. This is
utilized extensively in engineering in fields as diverse as OFDM communications, condition
monitoring systems etc.

The purpose of this part of the coursework is to investigate and document the development of the
FFT algorithm, from the development of the Fourier series through to the FFT. Ensure that the report
also covers the following areas:

1. The derivation of the radix-2 decimation in time FFT algorithm, giving the signal flow graph
for an 8 point FFT. (Describe explicitly the butterflies required in the FFT)
2. Discuss spectral leakage and how window functions can be utilized to reduce the effect of
this.
3. Discuss the computational advantage gained by using the FFT algorithms in terms of
multiplications and additions, and discuss what has to be done to the data before the
computations are performed (what is the algorithm for this?).

The above should be written as a report on the FFT, with the following question answered at the end:

4. Take the fft in Matlab of the sound file from laboratory 3 (swfaith.wav), plot the magnitude
and phase spectrums of the fft of this signal, labelling all axis. Repeat this in the range –f/2:f/2.
(Hint: Investigate plotting phase in Matlab).

Performing the above will provide information about the frequency spectrum calculated over the
duration of the entire signal, which removes all temporal information. Investigate and describe how
to obtain information in both the time and frequency domain for the above signal. Use Matlab to aid
you with your description, giving appropriate plots and explanation of the time-frequency
algorithm(s). Use the above signal and any other as required.

Comment clearly all code.

In this instance it is acceptable and advised to use existing software, online or existing within Matlab
to perform the above, providing appropriate referencing is utilized. (Hint: Search for Time Frequency
Matlab).

G Morison & S Sinanovic page 9

You might also like