Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ES3C5: Signal Processing

Coursework Lab Assignment Briefing Sheet v1.0

Submission Deadline:

12pm (noon) on Thursday 1 December 2022

Module Leader: Dr Adam Noel (D205, [email protected])

Autumn 2022

Target Completion Time for Average Performance: 14– 18 hours (not including time to learn the corresponding lecture material)

Note: This assignment is worth 30 % of your module mark.

Any changes made to this briefing will be listed here.

Health warning:  this assignment involves the generation and ltering of audio signals.  While the processing specified in this assignment should not make your signal louder than a conversational volume, a typo or other mistake in your code could manipulate your data in unintended ways and make your audio samples dangerously loud.   Take precautions when listening to processed audio signals for the rst time and whenever changes are made to the digital systems manipulating your audio .

1 Purpose

The following module learning objectives are applicable for this assignment:

· Model signals, filters and processes using computer packages.

· Design signal processing systems.

· Apply signal processing systems to classify signals and extract information.         · Evaluate signals and systems using laboratory test and measurement equipment.

The focus of this assignment is Parts 2 and 3 of the module, in particular content related to digital ltering and signal estimation.

2 Sessions and Support

There are 2 sets of in-person lab sessions as scheduled in Tabula to be held in A2.05a/b:

· Friday 18 November and Friday 25 November 1:00pm–3:00pm

· Friday 18 November and Friday 25 November 3:00pm–5:00pm

These sessions will begin and end promptly on time and you must attend your own sessions.

If you would like to change either of your sessions: You must nd someone to swap with and both of you must email the module leader to confirm that you agree.  Otherwise, your entry at the other session may be refused.

Extra support can be obtained during the module leader’s support and feedback sessions in D2.05: · Mondays 1:00pm– 1:50pm

· Tuesdays 3:30pm–4:20pm

Finally, there is a support forum for all Lab Assignments (link)under the Key Module Resources” heading on  Moodle.   Emailed questions will generally be re-directed to the forum unless the question is truly individual.

Email/forum cutoff: In fairness to all students, the module leader will not respond to Assign- ment queries (either forum or email) sent after 10pm on Wednesday 30 November until after the submission deadline, unless there is an internal (i.e., university-side) problem with submissions.

3 Academic Misconduct

Your submission must be your own. Plagiarism of any kind is not acceptable and can result in a mark of zero.  We have previously identified many cases of academic misconduct (including plagiarism) that have resulted in penalties for the assignments in this module.

It is expected that you will discuss the assignment with your classmates. However, you should keep the following best practices in mind to avoid having your work agged for academic misconduct:

· Write your own code, comments, and written answers. Start from the provided templates. · You should not adapt code from external sources, but if you do then they should be cited.

· Do not write your implementation together with another student and submit it as your own

work.  This includes talking through your implementation line-by-line.  Such cases count as academic dishonesty.

· Do not share your assignment les with another student. Allowing your work to be copied,

even if it is modified, counts as plagiarism.

· Do not use the les of another student or other source as a starting point for your own

submission.  This still counts as plagiarism and can be agged by our academic integrity processes, even if you make changes!

4 General Instructions

Heads up regarding names: These  instructions  include  precise  case-sensitive  guidance regarding names of les, directories, functions, and variables.  These must be followed exactly so that the marking scripts run correctly. There will be points deducted for any deviations. This may seem pedantic, but precise naming is standard practice in programming and is essential for writing code that other people can rely on.

The instructions to complete this lab assignment are as follows:

1. Download the zip le ES3C5_2022_2023_lab_data.zip (link) from the ES3C5 Moodle Page under the Assessment Information heading. Extract four les from the zip le:

· ES3C5_2022_2023_lab_template .m

· ES3C5_2022_2023_lab_template .docx

· u_lab .txt

· ES3C5_2022_2023_lab_recording .pdf

where  is your student number.

2. Download your signals le u_lab_signals .mat from the ES3C5 Coursework Lab As- signment Signals Files page (link) under the Assessment Information heading, where  is your student number.

· Note: This is a separate download so that you do not need to download everyone else’s

signals (over 100 MB).

3. Rename the template les as follows:

· ES3C5_2022_2023_lab_template .m to u_lab .m (where is your student num-

ber; don’t forget the u” prefix here!)  and place the le in your MATLAB working directory (this should be a directory where you have write privileges on your computer).

· ES3C5_2022_2023_lab_template .docx to u_lab .docx.

4.  Open    u_lab .m    and    rename    the    function    title    in    the rst    line    from ES3C5_2022_2023_lab_template() to u_lab() (where  is your student number). Do not change the output argument Answers or any of the code in the top-level function. You will be entering all of your code in the subfunctions.  Also, do not change the output arguments of the subfunctions or add any input arguments.

5.  Complete        the        prescribed        steps        in        the        Recording        Supplement (ES3C5_2022_2023_lab_recording .pdf) to record the audio data that you will use to an- swer the problems in Question 1. This data will be stored to the le u_lab_Audio .mat.

6.  Complete the problems listed below in Section 6 and refer to u_lab .txt for the func- tions and parameter values that you must use.   You will also need to load signals from u_lab_signals .mat and there is already a call to do this as needed in the template code. Enter the required code in the corresponding subfunctions in u_lab .m; you should not need to write your own functions. The code must calculate the answers using your as- signed parameters unless otherwise indicated.  Take care to use parameters with the correct units for each MATLAB function that you call. For example, you may need to do conversions between radian and Hz frequencies, or convert gains between linear and dB forms.

7. When a question includes plotting a gure, please account for the following:

(a) Every gure should be initiated by creating a new blank gure and your code should

not close any gures.

(b) The plot function calls must be inside the subfunction code for the question, but details

such as labels can be added after your solution function runs.

(c)  Carefully consider appropriate parameter ranges and axis scaling, e.g., is it better for a given axis to be linear or logarithmic?

(d) ALL submitted plots must have labelled axes.

(e) Figures must include your student number and question number at the top. (f) Each gure requested should be placed in u_lab .docx as a png image.

8. Include readable comments in your code that briefly summarise your work, especially critical steps. See the subfunction Q0 below (and in u_lab .m) as a template example:

function c0 = Q0()

% Assign answer to c0  (double value)

% Define triangle lengths

a0 =  2; %  1st side

b0 = 1; %  2nd  side

% Find length of hypothenuse

c0 = sqrt(a0^2 + b0^2); % Pythagorean theorem to find 3rd side

end

9. Run your code le from the MATLAB command line and write the output to a structure named Answers. Save Answers to a mat le named u<ID>_lab_Answers .mat. You can do these steps with the following code:

Answers = u<ID>_lab; % Runs assignment code save(’u_lab_Answers , Answers) % Writes output to file

10. Place   your   code le   u_lab .m,    signals le   u_lab_signals .mat,    audio file    u_lab_Audio .mat,    output le    u_lab_Answers .mat,    and    document u_lab .docx  into 1 folder named  u_lab,  and  compress  it  into  a  single  zip- file called u_lab .zip (where  is your student number).  The zip-file is what you submit to Tabula.

· Be sure to place the les into the named folder before zipping. This ensures that your

code is nested in its own subdirectory when unzipping.

5 Recording Supplement

Refer to ES3C5_2022_2023_lab_recording .pdf for instructions on recording and saving your audio.

5.1 Specication of the Data to Record

The (imaginary) premise is that, in the grand tradition of number-based songs (e.g., 867-5309, 46 and 2, One), you are recording your student number to use as a sample in a song.  You will record your voice saying (or singing?) only “ <ID>,” i.e., all 7 digits of your student number. This recording must be recorded to a single channel (mono) at a sampling frequency of 22.05 kHz and must be exactly 5 seconds long.  If the original recording is longer than 5 seconds, then you must shorten it to 5 seconds before saving to u_lab_Audio .mat. Refer to ES3C5_2022_2023_lab_recording .pdf for additional guidance.

6 Questions (Total: 100 points)

Please answer all of the following questions with reference to u_lab .txt for your specific parameter values.  Remember that all code to solve the following problems must be included in u_lab .m. Written answers in u_lab .docx are required where specified, including copies of output gures.

25  points  are  designated  as  being  part  of First Class Problems .    These  questions  are deliberately more challenging than the other assignment questions. While support can be sought to clarify what these questions are asking, instructors and lab demonstrators will not provide guidance on how to answer them.

Up to 30 Points in total can be deducted for poor coding style. Poor style includes:

· Displaying messages to the command line (e.g., by omitting semi-colons for output suppres-

sion)

· Insufficient use of code comments to explain key steps and demonstrate your understanding

of your implementation. However, succinctness is still appreciated.

Here are the questions:

1. (39 Points) This question concerns the generation and processing of an audio signal. Please complete the following:

(a)  (4 points) Ensure that you have completed the appropriate steps in the recording guid-

ance and have saved your audio recording vector with the correct specification to the file u_lab_Audio .mat. It is needed to proceed with Question 1. Load the record- ing into the Q1 subfunction. The subfunction has template code that you just need to update to do this.

·  Note:  There is nothing to calculate here; this part is being evaluated by the correct-

ness of your audio and loading it into the a1 subfunction.

(b)  (9 points) Design an FIR low pass digital lter for your audio signal with the windowing

method. Complete the following:

i. Using the window information tables in the lecture slides or notes, determine the shortest window type and length that will give a pass band ripple parameter below rp dB at frequencies less than fp1, and that has a stop band defined by frequencies above fstop1.  Remember that the sampling rate being used is fS   = 22.05 kHz. Assign window type as a case-sensitive character array (either rectwin’ , ’hann’ , ’hamming’ , or blackman’) to Q1 .w. Assign window length L to Q1 .L.

·  Note:  you do not need to trial different parameters to meet the specification;

you can assume that the tables are accurate.

ii. Use the fir1 function and the corresponding window function to determine the unscaled impulse response hb [n].  Use a cutoff frequency that is exactly halfway between fp1 and fstop1. Assign FIR impulse response vector hb [n] to Q1 .hb.

iii. Use your FIR low pass digital lter with the filter function (and not any function variant). Assign the low pass lter output to Q1 .audioLow.

(c)  (8 points) You wish to make your voice recording sound more interesting.  Consider applying a reverberation (reverb) effect that will simulate being in a large room.  You will use an all-pass reverberator with the following z-domain transfer function:

-A + z D

1 - Az D  ,

where A is the relative strength of the reverb effect and D is the baseline delay (measured in number of samples) associated with the reverb. Complete the following:

i. Using the reverb strength A1 and the delay time t1 (in seconds), determine the corresponding transfer function.  Assign the delay D  (in number of samples) to Q1 .D. Scale the b and a vectors for Hc (z) such that the first element of a is exactly

1. Assign b and a vectors for Hc (z) to Q1 .b and Q1 .a, respectively.

ii. Pass  your ltered  audio  signal  Q1 .audioLow  (not the  original  audio)  through the reverberator using the filter function.   Assign the reverberated output to Q1 .audioReverb.

(d)  (6 points) Your recording has become contaminated by a noise source. The contents of the noise source are in the vector n1 in your signals le u_lab_signals .mat.

i. Add the noise source vector n1 to your reverberated output Q1 .audioReverb. As- sign the noisy signal to Q1 .audioNoisy.

ii.  Calculate the fast Fourier transform (FFT) of Q1 .audioNoisy. Assign the FFT to vector Q1 .FFT.

·  See the Extra box 14.2 “Double-Sided vs Single-Sided FFT” in the lecture notes

to be aware that the MATLAB help examples present the FFT different from how you are expected to calculate it.  To answer this question you must find the double-sided FFT (which we cover) and not the single-sided FFT (which we do not cover).

iii. Plot the magnitude of this FFT output as a function of Hz frequency (i.e., a do- main of [0,22050) Hz should be visible). Ensure that the figure is sufficiently labelled as directed by the general instructions, including a label for the largest noise fre- quency component.  Save the FFT magnitude plot as a png le and include it in u_lab .docx.

(e)  (12 points; First Class Problem) Design an FIR lter to remove the largest noise

frequency component.

i. In no more than 4 lines of text in u_lab .docx, describe and justify a target FIR filter performance specification. The specification should be sufficient to assess a candidate design by inspection of the magnitude of its frequency response.

ii. Design a lter that meets your target specification.  Assign the lter impulse re- sponse to Q1 .he.

iii. Test  your lter  design.   Pass  your  noisy  audio  signal  Q1 .audioNoisy  through your  designed lter  using  the  filter  function.    Assign  the ltered  output  to Q1 .audioNotNoisy.

iv.  Create a suitable plot that assesses the test of your design. Ensure that the gure is sufficiently labelled as directed by the general instructions.  Save the plot as a png le and include it in u_lab .docx.

v. Birefly (in no more than 2 lines of text) explain in u_lab .docx whether your plot validates the design.

2. (21 Points) This question concerns interference and aliasing.

You are an engineer at SpaceZ and are receiving signals from the new deep space satellite deployed by SpaceY. You are tuning your terrestrial hardware using transmissions from the satellite and have collected a sequence of time-series data y2 that was sampled at frequency f2s. You are expecting to observe a signal of frequency f_satellite from the satellite.

(a)  (8 points) Determine the spectra associated with y2 as follows:

i.  Calculate the fast Fourier transform (FFT) of y2. Assign the FFT output to vector Q2 .FFT.

·  See the Extra box 14.2 “Double-Sided vs Single-Sided FFT” in the lecture notes

to be aware that the MATLAB help examples present the FFT different from how you are expected to calculate it.  To answer this question you must find the double-sided FFT (which we cover) and not the single-sided FFT (which we do not cover).

ii. Each element in the FFT is associated with a frequency.   Create the vector of frequencies associated with Q2 .FFT. Assign the vector of frequencies to Q2 .fRange.

iii. Plot the  magnitude  of  Q2 .FFT as a function of Hz frequency  (i.e., a domain of [0,f2s) Hz should be visible).  Ensure that the gure is sufficiently labelled as di- rected by the general instructions.  Include labels that identify all spectral peaks associated with target frequency f_satellite. Save the FFT magnitude plot as a png le and include it in u_lab .docx.

(b)  (5 points) It should be apparent from your FFT magnitude plot in Q2(a) that there

are unexpected signal components at other frequencies.  You can assume that there is no aliasing.  Thus, based on the plot in Q2(a), at what distinct frequencies do you expect there to be interfering sinusoids? Briefly (in no more than 3 lines of text) explain your approach in u_lab .docx.  Assign the unexpected frequencies (each rounded to nearest Hz) to row vector Q2 .fInter.

(c)  (8 points; First Class Problem) Suppose that one of the unexpected signal com- ponents in y2 could be an alias. Complete the following:

i.  Calculate the lowest frequency signal (in Hz and rounded to the nearest Hz) that could lead to any of the unexpected signal components as an alias.  Briefly (in no more than 3 lines of text) explain your approach in u_lab .docx. Assign this frequency (in Hz) to Q2 .fFirst.

ii.  Create a signal with frequency Q2 .fFirst and plot its FFT to demonstrate that it would result in the alias as predicted. Ensure that the gure is sufficiently labelled as directed by the general instructions. Save the FFT magnitude plot as a png le and include it in u_lab .docx.

iii. Briefly   (in  no  more  than 3 lines  of  text)  propose  a  suitable  solution  in u_lab .docx to prevent this signal from creating the alias without having any other impact on y2.

3. (20 Points) This question concerns estimation of an unknown signal.

You are a control engineering consultant and are visiting the factory of NewWave Mobile to inspect a heating chamber that will be used to stress-test their new drone communication chips. Based on the chamber specification, you expect that the transient heating profile will behave according to the general equation provided in u_lab .txt where y3(t) is the temperature in degrees Celsius and w3(t) is the noise signal.

You have collected noisy thermometer readings in column vector y3 in your signals le u_lab_signals .mat. Your data were collected starting from time t = 0 at the constant interval Ts3 in your parameter le. Please complete the following:

(a)  (3 points) Construct the linear model observation matrix Θ needed to estimate the

unknown parameters A3, B3, and C3 (in that respective order). Assign Θ to Q3 .Obs.

(b)  (2 points) Apply linear model estimation to estimate the unknown parameters A3, B3,

and C3.  Assign these three constants in the same order to the 3 × 1 column vector Q3 .param.

(c)  (1 point) Use the parameter estimates to predict the temperature for the same times at which the sensor values were taken.  Assign the predicted temperatures to column vector Q3 .yHat.

(d)  (1 point) Calculate the mean square error of the predicted temperatures.  Assign the scalar mean square error to Q3 .mse.

(e)  (5 points) Compare the measured temperatures and predicted values in the time domain

as follows:

i.  Compare the predictions with the actual sensor values on the same axes in a single time-domain plot, where the y-axis is the temperature in degrees Celsius. Save the plot as a png le and include it in u_lab .docx.

ii. Briefly (in no more than 2 lines of text) comment in u_lab .docx on the possible accuracy of the model as shown in this plot.

(f)  (8 points) Compare the spectra of the temperature sensor readings with those of the

estimated temperatures, as follows:

i.  Calculate the fast Fourier transform (FFT) of y3. Assign the FFT output to vector Q3 .yFFT.

·  See the Extra box 14.2 “Double-Sided vs Single-Sided FFT” in the lecture notes

to be aware that the MATLAB help examples present the FFT different from how you are expected to calculate it.  To answer this question you must find the double-sided FFT (which we cover) and not the single-sided FFT (which we do not cover).

ii. Each element in the FFT is associated with a frequency.   Create the vector of frequencies associated with Q3 .FFT. Assign the vector of frequencies to Q3 .fRange.

iii.  Calculate the fast Fourier transform (FFT) of Q3 .yHat. Assign the FFT output to vector Q3 .yHatFFT.

iv. Plot the  magnitude  of both  FFT outputs as a function of Hz frequency  (i.e.,  a domain of [0,1/Ts3) Hz should be visible).   Include both sets of spectra on the same axes. Ensure that the gure is sufficiently labelled as directed by the general instructions, including labels that identify all relevant spectral peaks. Save the FFT magnitude plot as a png le and include it in u_lab .docx.

v. Briefly (in no more than 3 lines of text) comment in u_lab .docx on the possible accuracy of the model as shown in this plot.