matlab代写-DEC 11 2019
时间:2020-12-15
Computational Methods ASSESSMENT DEC 11 2019
Prof. Catherine O’Sullivan
INSTRUCTIONS - READ CAREFULLY:
1. This is a coursework assessment however no collaboration between
students is allowed.
2. Access to the internet and email has been disabled on your computer
and cannot be used. Removable storage (e.g. usb keys) may not be
used. The network is being monitored and students violating these
conditions will be identified and disciplined. HOWEVER YOU
CAN ACCESS THE MATLAB HELP FACILITIES
3. All roughwork should be completed on the final two sheets of this
handout.
4. These guidelines with your name on them should be submitted at the
end of the assessment.
5. Follow the instructions provided for saving your files. Please save your
work continuously to the h: drive to avoid any loss of files.
6. Your name and student id number should be included in all MATLAB
files as a comment.
7. The assessment contains two compulsory questions. Each question is
worth 25 marks.
I have read and understand these instructions:
• Name (Print clearly):
• Signature:
1
Problem 1
Part A
Heyman (1998) proposed that the following equation can be used to plot
the shape of the dome of St. Paul’s Cathedral:
z = 0.7206
[
r3 + 0.3338r7 + 0.0496r11 + 0.0041r15 + 0.0002r19
]
(1)
where z is the elevation of the roof and r is the radial distance from the
centre of the dome.
Develop a function called stpaulsdome.m that takes as input two one
dimensional arrays x and y that each have the same number of entries. The
average value of the numbers stored in each array should be 0. The function
should calculate a 2D array of data points that correspond to surface of the
dome according to Heyman’s equation (Hint: take r =

x2 + y2).
The function you develop should for loops for all repeated calculations
(i.e. do not use implied loops).
Reference:
www.jstor.org/stable/532075
[13 marks]
Part B
Develop a MATLAB script called problem1.m that
1. Efficiently creates two, one-dimensional arrays, each having uniformly
spaced data between -1 and 1.
2. Uses the function stpaulsdome.m to calculate the elevation of the
surface of the dome at the defined grid points.
2
3. Visualizes the shape as a 3-D surface.
If you have implemented the equation correctly the surface will be upside
down relative to what we expect to see. Develop a second figure that uses an
efficient approach to plot the shape of the roof with the correct orientation.
[12 marks]
3
Problem 2
Part A
Develop a MATLAB function called forwarddiff that takes as input a two
one-dimensional array x and y and returns the the approximate derivative
dy
dx .
Use for loops for any calculations required, rather than using intrinsic
MATLAB functions or implied loops.
[8 marks]
Part B
You should find a datafile called“UKcensus.txt” on your S-drive. This
file contains the UK census data between 1971 and 2011 which are recorded
at 10 year intervals. The first column contains the year. The second column
gives the UK population.
Develop a MATLAB script file called Problem2.m that
1. Reads in the data stored in the file UKcensus.txt.
2. Uses linear interpolation to estimate the UK population for each year
from 1971 ro 2011.
3. Determines the best fit line to the data to estimate the rate of increase
in population over the past 10 years.
Does the slope of the best fit line to the data give an accurate estimate
of the rate of population growth in 2011? (Explain by adding a comment
in your m file) Make a better estimate using the available data and the
function you have developed.
How might you estimate the current rate of population growth? (Explain
by adding a comment in your m-file). [17 marks]
4
ROUGHWORK PAGE 1
5
ROUGHWORK PAGE 2
6



























































































essay、essay代写