matlab codes and report in 3 days
i have more files but talk to me first
CEE 384 Numerical Methods for Engineers Summer 2018 Arizona State University
School of Sustainable Engineering and The Built Environment Dr. Lou
Page 1 of 3
ML Assignment #4
Released: 7/27/2018 Due: 8/2/2018
Please read βMATLAB Assignment Submission Guidelinesβ in Blackboard before submission. Not
following the guidelines will result in loss of credit, even though you may have the correct answer(s).
Write code of your own and answer the questions in this assignment.
Submit your code through Cody Coursework.
Submit a report through Blackboard
Interpolation is the basis of this assignment.
Problem 1: Spline Interpolation
To maximize the catch of bass in a lake, it is suggested to throw the line to the depth of the thermocline
layer. The characteristic feature of the thermocline layer is the sudden change in temperature. (Read
textbook Ch 05.00C for the full story). Table 1 shows some measured temperature vs. depth data. In
this problem, you will write MATLAB functions to implement quadratic spline interpolation and identify
the depth of the thermocline.
Table 1 Temperature vs Depth for a Lake
Temperature, π¦(β) Depth, π₯(π)
19.1 0
19.1 β1
19 β2
18.8 β3
18.7 β4
18.3 β5
18.2 β6
17.6 β7
11.7 β8
9.9 β9
9.1 β10
1) Quadratic spline interpolation
Explain the essential ideas of quadratic spline interpolation in the report. Use simple language that a
bright high school senior can understand.
CEE 384 Numerical Methods for Engineers Summer 2018 Arizona State University
School of Sustainable Engineering and The Built Environment Dr. Lou
Page 2 of 3
Write a MATLAB function to perform quadratic spline interpolation. Do NOT call the built-in βsplineβ
command and write you own code for quadratic spline interpolation by setting up the equations and
solving for the unknown coefficients.
Your function should meet the following requirements:
It should be named qspline
The function should have one input argument: the query point ππ β [βππ, π].
The function should have one output argument, a ππ Γ π column vector that contains two
parts:
1) the coefficients of the piecewise polynomial in descending powers stored in the first 30
elements of the column vector. In other words, your code should return
[π0, π0, π0, π1, π1, π1, β¦ ]π for the spline
π¦ = {
π0π₯2 + π0π₯ + π0 π₯ β [β10, β9]
π1π₯2 + π1π₯ + π1 π₯ β [β9, β8]
β¦ β¦
2) the estimated value at query point, stored in the last element of the vector.
Use all of the data points.
Assume the first spline is linear.
Use βforβ loops to help you set up the equations (in matrix form) instead of typing the equations
manually. Demonstrate this part of your code in the report.
Use proper MATLAB built-in command to solve for the unknown coefficients once the equations
are setup in matrix form.
Use a βforβ loop to display the interpolated quadratic spline (the piece-wise equations).
Demonstrate this part of your code in the report.
Display the estimated temperature at the query point in the command window.
Use a βforβ loop to plot the interpolated quadratic spline. Demonstrate this part of your code in
the report. Also mark the given data points as well as the query point in the figure. Properly
label the figure, the axes, and the data points.
Your solution will be tested three times with randomly generated input arguments.
2) Compare with built-in command and identify the depth of the thermocline
a. Consult the MATLAB Help feature and explain the use of built-in command βspline(x,y,xq)β.
Which interpolation method does this command use?
b. What is the output of built-in command βspline(x,y)β? How can the output of this command be
used? How is the command different from command βspline(x,y,xq)β?
c. Use the built-in command βspline(x,y)β and plot the resulting spline using a βforβ loop. In the
same figure, plot the resulting quadratic spline from question 1). Compare the two splines and
discuss your observations.
d. Base on the figure, how deep is the thermocline layer? Your answer could be a range. Explain
your answer.
CEE 384 Numerical Methods for Engineers Summer 2018 Arizona State University
School of Sustainable Engineering and The Built Environment Dr. Lou
Page 3 of 3
Problem 2: 4th-order Polynomial Interpolation
Consider the same application as in Problem 1. In this problem, you will write MATLAB functions to
implement polynomial interpolation and compare it with cubic spline interpolation and polynomial
regression.
Write a MATLAB function to perform 4th-order polynomial interpolation. After it has chosen 5 base data
points correctly according to the input (query point), your code can then call the built-in polyfit
command.
Your function should meet the following requirements:
It should be named fourthInterp
The function should have one input argument: the query point π₯π β [β10, 0].
The function should have one output argument that is a π-by-π row vector that contains two
parts:
1. the five coefficients of the polynomial in descending powers stored in the first five
elements;
2. the estimated value at query point, stored in the last element.
Choose appropriate base points to fit a 4th-order polynomial based on the input (query point).
Avoid βhard codingβ. When two data points are of equal distance to the query point but only
one can be chosen, choose the point further away from 0. Use an βifβ statement to construct
three cases that can accommodate all possible query points. Demonstrate this portion of you
code in the report.
Display the interpolated polynomial equation and the estimated temperature at the query point
in the command window.
Plot the following in the same figure:
o Given data points
o Results from cubic spline interpolation (use built-in βsplineβ command)
o Results from fourth-order polynomial regression (use built-in βpolyfitβ command, recall
details from MATLAB Tutorial 4)
o Chosen base points for the four-order polynomial interpolation (use a different color or
marker to highlight them)
o The interpolated polynomial
o The query point on and the fourth-order polynomial interpolation curve
Include title, axis titles, and legend in the figure.
Your solution will be tested four times with known and randomly generated input arguments.
Test 1: π₯π = 2.5
Test 2: π₯π = 7.5
Test 3: with randomly generated query point
Test 4: with randomly generated query point
Top-quality papers guaranteed
100% original papers
We sell only unique pieces of writing completed according to your demands.
Confidential service
We use security encryption to keep your personal data protected.
Money-back guarantee
We can give your money back if something goes wrong with your order.
Enjoy the free features we offer to everyone
-
Title page
Get a free title page formatted according to the specifics of your particular style.
-
Custom formatting
Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.
-
Bibliography page
Donβt pay extra for a list of references that perfectly fits your academic needs.
-
24/7 support assistance
Ask us a question anytime you need toβwe donβt charge extra for supporting you!
Calculate how much your essay costs
What we are popular for
- English 101
- History
- Business Studies
- Management
- Literature
- Composition
- Psychology
- Philosophy
- Marketing
- Economics