Question

Design a MATLAB code to construct a natural cubic spline P(a) that passes though the points (1,1), (4, I), (7, 4), (10, TD), (13, 13) 16 (a) Use the contsructed cubic spline to interpolate a 3; (b) Find the error e1 li P(3)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

% Initialize 2 arrays with the given points

% one for x coordinate and one for y coordinate

x = [1, 4, 7, 10, 13, 16];
y = [1, 1.0/4.0, 1.0/7.0, 1.0/10.0, 1.0/13.0, 1.0/16.0];

inter = 3;
% use the predefined spline function in matlab

% a)

% the parameter are the array of x coordinate, the array of y coordinate and the value which we want to interpolate
inValue = spline(x, y, inter);
% b)

%To find the error we use the abs function which gives the absolute value (Positive value) of the variable passed as a parameter.
e1 = abs(1.0/3.0 - inValue);

% Answers-

% a) 0.3931

% b) 0.0597

Add a comment
Know the answer?
Add Answer to:
Design a MATLAB code to construct a natural cubic spline P(x) that passes though the points...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT