I try to interpolate the function with given datas. I am using Matlab function 'csape' but, I am not sure this is a Natural Cubic Spline Interpolation or just Cubic Spline.
I just found out that Natural Cubic Splines are the one with the condition that is Secondary Derivative is equal to 0. However, I am not sure that to take 2nd derivative and rearrange my code.
I have this code written by me and want to ensure that is accurate and second derivatives are 0. What should I add to find out?
%Data
x= [-2 6 2.4 7.8];%Function
y=cos(x);%Interpolation
cubic=csape(x,y);%Plotting Data and function outputs
figure;plot(x,y,'ro');hold on;%Plotting interpolation
fnplt(cubic,'b',2);%Needs
grid on;xlabel('x');ylabel('f(x)');axis([-3 9 -2 1.5]);title('Natural Cubic Spline Interpolation');legend('Data Points','Cubic Spline');
Best Answer