Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

above are the question to write a MATLAB code without using spline function. thi

ID: 3736536 • Letter: A

Question


above are the question to write a MATLAB code without using spline function. this photo below shows how the f matrices should look like after writing n, n-1 , n-2 equations. before finding the P and B matrices we need F matrices. can you also send the pics of failed plots too.


Rules: you cannot use the built in MATLAB spline function and you cannot look at or copy any code other than what is provided to you in this document No Assume you are given a set of independent (x) and dependent (Y) data points and you want to interpolate the values of the data between the given points X = [X1,X2,X3, X4] For this data, the length is n = 4 You will need n-1 3 estimation functions (1 between each set of data points) For cubic spline interpolation, these estimation functions look like: We can use the conditions for cubic spline interpolation covered in class to get the following set of linear equations (shown here in matrix form) 0 -2x 0 3x3223 10 6x2 0 -6X32 F4 F5 F6 F7 F 8 FS

Explanation / Answer

Given that,

Assume you are given a set of independent (X) and dependent (Y) data points and you want to interpolate the values of the data between the given points.

X = IXt, x2, x3, x41 Y = [Y1, Yz, Y3, Y41

For this data, the length is n = 4 you will need n-, 3 estimation functions (1 between each set of data points)

For cubic spline interpolation, these estimation functions look like

: S1, = a1x3 + b1x2 + cix + di for xi 5 x 5 X,

S2 = a2x3 + b2x2 + c2x + c12 for x2 < x < x,

S3 = a3x3 + b3x2 + c3x + d3 for x3 < x < x4

Program:-

x = [0 1 2.5 3.6 5 7 8.1 10];

y = sin(x);

xx = 0:.25:10;

yy = spline(x,y,xx);

plot(x,y,"o",xx,yy)

x = -4:4;

y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];

cs = spline (x,[0 uy 0]);

xx = linspace(-4,4,101);

plot(x,y,"o',xx,ppval(cs,xx).'-');

t = 1900:10:1990;

p = [75.995 91.972 105.711 123.203 131.669 .....

150.697 179.323 203.212 226.505 249.633];

spline(t,p,2000)

x = pi*[0:.5:2];

y = [0 1 0 - 1 0 1 0;

1 0 1 0 - 1 0 1];

pp = spline(x,y);

yy = ppval(pp, linspace(0,2*pi,101));

plot(yy(1,:), yy(2,:),'-b',y(1,2:5),y(2,2:5),'or')

axis equal

x = 0:.25:1;

Y = [sin(X); cos(X)];

xx = 0:.1:1;

YY = spline(x,Y,xx);

plot(x,Y(1,:),'o',xx,YY(1,:),'-')

hold on

plot(x,Y(2,:),'o',xx,YY(2,:),':')

hold off

x = 0:25;

y = besselj(1,x);

xq2 = 0:0.01:25;

p = pchip(x,y,xq2);

s = spline(x,y,xq2);

plot(x,y,'o',xq2,p,'-',xq2,s,'-'.)

legend('Sample Points,"pchip",spline')