Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write matlab for cubic spline show output %X=[-2.4061 -1.0830 -0.6440 -0.4068 -0.2448 -0.1158 0 0.1158 0.2448 0.4068 0.6440 1.0830 2.4061] %Y=[-.0.3984 -0.7611 -0.9688 -0.9791 -0.7899

Write matlab for cubic spline show output

image text in transcribedimage text in transcribed

%X=[-2.4061 -1.0830 -0.6440 -0.4068 -0.2448 -0.1158 0 0.1158 0.2448 0.4068 0.6440 1.0830 2.4061]

%Y=[-.0.3984 -0.7611 -0.9688 -0.9791 -0.7899 -.04397 0 0.4397 0.7899 0.9791 0.9688 0.7611 0.3984]

% interpolation point x

% x = 1

%function y = cubic_spline(X, Y, x)

%y should be output as a number when x is plugged into S(x) onece the S(x) polynomial is found

%please show output

image text in transcribed

Write a MATLAB function to implement the natural cubic spline in Algorithm 3.4. Note that the index should run from 1 instead of 0 that is used in the textbook. This is because MATLAB does not allow index 0. Your function should use the same order of input below. Note that we do not return a,bi,ci,dy as in the algorithm. Instead, we calculate the spline at x. Since the cubic spline is a piecewise polynomial, one needs to locate the subinterval [xi x+1l that contains x before calculating S(x) - StCx). function y = cubic spline (X,Y,x) %X=numbers x 1 x 2 x n % Y-values f (x 1) f (x 2) f (x n) % x-interpolation point x % y- spline value at x, i.e. s(x) % your implementation below end Save your function in cubic_spline.m. Then, compute the natural cubic spline for the data below. -2.4061 | 1.0830 | 0.6440 | 0.4068 | -0.2448 | -0.1158 0 f (x) | -0.3984 | -0.76 1 1 | -0.9688 | -0.9791 | -0.7899 | -0.4397 | 0 (continued) 0.11580.2448 0.4068 0.6440 1.08302.4061 f(x) 0.43y/ e1.7) 0.7899 ga97 0.9791 gaa3313 0.:/611. 0.:Was 0.3984 Natural Cubic Spline ALGORITHM 3.4 To construct the cubic spline interpolant S for the function f, defined at the numbers X0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions