Writing a cubic function
Show older comments
When the grader enters cubic(x,y), your function should return a plot of the cubic spline interpolant (with natural boundary conditions) for arrays x and y. The plot should also include markers for the data points. If you use multiple .m les to accomplish this, send them all to the grader. There is a code outline on Canvas to help you with this implementation. You may want to test your function with the following data:
x 0.06 0.47 1.01 1.50 2.05 2.53 2.99 3.44
y 1.0499 1.3274 1.3588 1.2550 1.6322 2.5523 3.4462 3.6684
With this test data:
(a) The spline coecients are (ai's in the rst column, bi's in the second, and so on):
1.0499 0.7946 0 -0.7004
1.3274 0.4414 -0.8614 0.2810
1.3588 -0.2431 -0.4061 0.9592
1.2550 0.0497 1.0038 0.2776
1.6322 1.4059 1.4618 -0.8275
2.5523 2.2372 0.2702 -1.9766
3.4462 1.2310 -2.4575 1.8204
(b) With that data, a few (x; S(x)) values of the interpolant include: (0:8; 1:3893), (2:45; 2:3755), and (3:23; 3:6253).
(c) The plot of the interpolant:
1 Comment
Steven Lord
on 9 Mar 2017
If you post what you've done to try to solve this problem and ask a specific question you may receive some suggestions about how to move forward.
Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!