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

Calculate your order
275 words
Total price: $0.00

Top-quality papers guaranteed

54

100% original papers

We sell only unique pieces of writing completed according to your demands.

54

Confidential service

We use security encryption to keep your personal data protected.

54

Money-back guarantee

We can give your money back if something goes wrong with your order.

Enjoy the free features we offer to everyone

  1. Title page

    Get a free title page formatted according to the specifics of your particular style.

  2. Custom formatting

    Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.

  3. Bibliography page

    Don’t pay extra for a list of references that perfectly fits your academic needs.

  4. 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

Type of paper
Academic level
Deadline
550 words

How to place an order

  • Choose the number of pages, your academic level, and deadline
  • Push the orange button
  • Give instructions for your paper
  • Pay with PayPal or a credit card
  • Track the progress of your order
  • Approve and enjoy your custom paper

Ask experts to write you a cheap essay of excellent quality

Place an order