Question: Problem 4 (programming): Create a MATLAB function named my cubic spline.m to perform interpolation using cubic spline method with clamped end-conditions. Download the template

Problem 4 (programming): Create a MATLAB function named my cubic spline.m to

Problem 4 (programming): Create a MATLAB function named my cubic spline.m to perform interpolation using cubic spline method with clamped end-conditions. Download the template for the function from the homework 6 folder in CANVAS. The function takes in the data given at the knots, xi and yi, the first derivative at the first knot, sprime x1, the first derivative at the last knot, sprime xn, as well as the target x value, xtarget The function returns the interpolated value ytarget Here, xi and yi are vectors while sprime x1, sprime xn, xtarget and ytarget are scalars. You are not required to follow the template; you can construct the function in your way. . . Use function my cubic spline.m and the seawater temperature data in table 1 to per- form the following exercises. Also, set the first derivative of the spline at the knot z = - 12m to be equal to 0.0C m- 1 and the first derivative at the knot z = - 330m to be equal to 0.0082C m 1. (a) Estimate the temperature at depth z = -150 m using all knots. Put the answer in p4a . . (b) Create a vector depth = [-330:2:-12] Estimate the temperature for every element in vector depth and store them in vector temperature Use all knots to perform the interpolation. Make a figure 4, e.g. figure(4) Use a solid line to plot temperature versus depth with temperature on the x-axis and depth on the y-axis. Also, use symbols to plot all knots on table 1. Remember to give the figure a legend and a title and label the axes. Set p4b = 'See figure 4. (c) Comment on the difference between the cubic spline interpolation result seen here and the Lagrange interpolation result obtained in problem 5 of homework 5. Give the answer as p4c =

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mechanical Engineering Questions!