matlab代写-DEC 12 2018
时间:2020-12-15
Computational Methods ASSESSMENT DEC 12 2018
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 Develop a function called hyperpara.m that takes as input two
one dimensional arrays x and y that each have the same number of entries.
The function should also take as input two scalar numbers a and b. The
function should calculate a 2D array of data points that correspond to the
elevation of a hyperbolic paraboloid surface evaluated at the points stored
in x and y.
The equation of the hyperbolic paraboloid is given by
z =
y2
b2
− x
2
a2
(1)
The function you develop should not use implied for loops.
[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 -10 and 10.
2. Uses the function hyperpara.m to create evaluate the hyperbolic paraboloid
surface for the two arrays you have created. Take values of 70 for both
a and b.
3. Visualizes the hyperbolic paraboloid as a 3-D surface.
4. Develops a contour plot of the hyperbolic paraboloid.
[12 marks]
2
Problem 2
Part A
Develop a MATLAB function called avg that takes as input a one-
dimensional array and returns the average of the numbers stored in that
array.
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“kensington.txt” on your S-drive. This
file contains the traffic data recorded on the A4 in Kensington (adjacent to
Earl’s Court Road) between 2000 and 2017.
1. The first column contains the year.
2. The second column gives the average number of pedal cycles per day
passing the monitoring point.
3. The third column gives the average number of motorcycles per day
passing the monitoring point.
4. The fourth column gives the average number of cars and taxis per day
passing the monitoring point.
5. The fifth column gives the average number of buses and coaches per
day passing the monitoring point.
6. The sixth column gives the average number of light good vehicles per
day passing the monitoring point.
3
Develop a MATLAB script file called Problem2.m that
1. Reads in the data stored in the file kensington.txt.
2. Plots, on a single figure, the average number of vehicles of each type
passing the monitoring point versus the monitoring year.
3. Calculates the average number of vehicles of each type that passes the
monitoring point each day over the entire period of monitoring using
the function avg.m, i.e. calculate the average number of pedal cycles
that passes the point each day between 2000 and 2017, etc..
4. Outputs each of the 5 average values to a textfile called trafficdata.txt
(you may recall use of the fopen function this term).
[17 marks]
4
ROUGHWORK PAGE 1
5
ROUGHWORK PAGE 2
6




























































































essay、essay代写