You are on page 1of 3

# MOD002564 Computer Modelling

Coursework - assignment
Due: 06/01/2016. Submit the assignment via the iCentre using the formal submission sheet.
This assignment carries 50% of total mark for this module.
Write the Matlab code for generating, analysing, displaying and playing of a recorded and
simulated trumpet sound.
Short introduction:
The trumpet signal can be expressed using Fourier series as a sum of sinusoids at frequencies of
{494, 2x494, 3x494 . . .} hertz. Therefore, the nine-term finite Fourier series approximation of
the trumpet signal is:
9
ec.1
trumpet _ sim t = ck cos 2k 494t k
k =0
where trumpet_sim(t) is the amplitude of the simulated signal at moment t, ck is the coefficient of
the term k, k is the phase of term k. Their values are given in table below:

()

c0 = 0
c1 = 0.1155
c2 = 0.3417
c3 = 0.1789
c4 = 0.1232
c5 = 0.0678
c6 = 0.0473
c7 = 0.0260
c8 = 0.0045
c9 = 0.0020

Expected work:
1. Write a script that calculates the amplitude of the simulated trumpet signal (given in ec. 1) at
time t = 0.03 and t = 1
10 marks
2. Describe how the amplitude of the signal trumpet_sim changes in a time period of 1 second.
To do this, write a script that plots the amplitude versus time. Comment your results in the
report. Include appropriate graphs in the report.
The created code must cover the following stages:
o Make a time vector (from 0 - 1 in steps of 1/44100)
o Calculate the amplitude of the signal for a period of 1 second
o Plot the curve of trumpet_sim versus time for the first 800 samples
20 marks
1

3. Analyse the signal changes in time. For that, write a script that calculates the maximum and
minimum values of the signal. Comment your results and include appropriate graphs. The
script must cover the following stages:
o Calculate the global maximum and the minimum values.
o Create a function that calculates the local minimum and maximum values of the
signal and gives the time when they occur.
o Ask the user to enter a time value between 0 and 1 from the keyboard
o Call the function the calculates the signal amplitude at the time given by the user
o Plot the trumpet_sim signal versus time for the first 800 samples and indicate on
the graph with different markers the global and local minimum and maximum
values
20 marks
4. Load in Matlab the trumpet signal provided (trumpet_rec.wav). Analyse the differences
between the simulated signal (trumpet_sim created using equation 1) and the recorded one
(trumpet_rec). Comment your results and include appropriate graphs. The script must
cover the following stages:
o Load the trumpet_rec.wav signal and store it in a variable named trumpet_rec.
o Plot the trumpet_rec and trumpet_sim signals on a graph called signals
o The difference between the value of trumpet_rec and x at a specific time is called
the absolute error. Create a function that counts the number of absolute errors that
exists between the two signals.
o Create two functions to calculate the mean square error (MSE) and the standard
deviation.
o Plot the error signal on the signals graphs using a separate y axis. Explain in the
report the advantage of using graphs with multiple axis.
20 marks
5. Create a Graphical User Interfaces (GUI) which loads an *.wave file and performs the
o Filters the signal to remove the noise (One filter that can be used is the 5-point
moving average filter: each sample of the filtered signal is calculated as the
average of 5 samples centred on the sample to be filtered: xn = (xn-2+ xn-1 + xn +
xn+1 + xn+2)/5);
o Reverses the signal (in a signal whit n samples, sample 1 is swapped with sample
n, sample 2 with sample n-1, etc)
o Introduces echo: adds to the signal itself samples from 1000 samples ago with the
amplitude decreased by 0.7 (multiplied by 0.7).
o Plays and plots the signals
20 marks
Marks for Presentation:
Structure (sections, introduction/conclusions/appendices), Logic, Understanding, Flow,
Lose marks for: lack of coherence, poor explanation, poor grasp, lack of sections, poor layout.
10 marks

Instructions:
You need to write appropriate Matlab programs to perform the operations required, commenting