ENGR5156EL-无代写
时间:2023-03-30
ENGR 5156EL Research Methods
Assignment: MATLAB exercise
This exercise is intended to build upon the MATLAB Onramp training you have already completed.
Objective: Your task will be to develop MATLAB code that will i) read the information in the file into
arrays / vectors / matrices, ii) use this information to estimate the density (of water) when the
temperature and pressure is specified, and iii) demonstrate the use of your MATLAB property lookup
procedure by programmatically preparing a graph of estimated liquid water density values for a suitable
range of temperatures (your choice) and a pressure of 101.325 kPa.
Supplied data: A data file: ‘water density.csv’ is supplied for your use. In the file containing
precomputed water density values the first row in the file is the pressure in kPa and the first column is
the temperature in K. The water density values in the remaining rows/columns are in kg/m3. As you
might expect, these are all around 1000 kg/m3.
Contextual Background: Property lookup functions from pre-calculated tables like this are common
tools in engineering programs that speed up the calculation process without resorting to a) simplifying
assumptions that may more dramatically impact the accuracy of the calculation, or b) repeated
evaluations of complex equations of state.
Deliverables: Your submission will be your MATLAB code, submitted as .m files, and a pdf containing
your graph. Please take care to remember advice given on graph formatting and data representation in
prior Research Methods sessions (“Get it right in black and white”).
Support: Course GTA Maryam Pourmahdavi is well versed in MATLAB, many other graduate students
within the Bharti School of Engineering and Computer Science also know it well, and I like to think I am
pretty good with it too. If you get stuck, or need help in completing the assignment, Maryam or I can be
contacted by you via the Research Methods discussion forum, where we will respond to questions from
individuals for the benefit of all. I am happy to entertain delegations in my office too – by appointment.
More detailed guidance / instructions
You may implement your MATLAB program using any of the basic tools: script, function, or class.
Whichever implementation style you choose to implement, please make sure there is sufficient
documentation that I can read and understand your code. For those who are unaware, the ‘%’ character
can be used to write comments in line with the code. If you implement your code in script form, please
make sure to declare your key search variables at the top, where I can find and modify them without
combing through the code.
You will need to implement some sort of search function to complete the table lookup. The simplest
solution I will accept is a simple search that reports the nearest result. If you’re feeling a little more
adventurous, try implementing a binary search to improve speed and/or perform linear interpolation to
improve accuracy. For a guide on how to implement a binary search, there is a good one located at
https://www.tutorialspoint.com/data_structures_algorithms/binary_search_algorithm.htm. I would
make one correction to the instructions in that tutorial: if you are implementing a binary search for a
nearest or interpolated result rather than an exact match, you need to be able to find a result between
elements. The code in the example shown should then read “low = mid” where it currently reads
“low = mid + 1”. If you were looking for the interval that contains the value “28”, it would not be
safe to remove the element containing “27” from the search.
Grading
You will need to complete and submit your MATLAB Onramp training certificate to qualify for a grade as
below.
I will test your MATLAB code. The comments in the header area of your .m file should tell me how you
expect me to use your procedure or function. I will submit a pressure and temperature to your code,
knowing what the answer for the water density should be, and if the answer comes back correct then
you will pass the assignment with a B.
Successful implementation of binary search and linear interpolation will be worth an A+.
If you feel comfortable enough with MATLAB or with programming in general to attempt the more
advanced solution, I recommend you do so. I have personally found that being able to implement basic
algorithms like this has been invaluable in research and in engineering practice more generally.
essay、essay代写