MATLAB: How to construct cubic splines

plotting

Hello, I am trying to implement the following code in Matlab but it dose not work.
x = 2*pi*[0 1 .1:.2:.9];
y = cos(x);
csp = csape( x, y, 'periodic' );
hold on
fnplt(csp,'g')
hold off

Best Answer

Do you have the curve fitting toolbox? CSAPE is part of that TB. (It used to be in the splines TB but that got merged into the curve fitting TB some years ago.)
My SLM toolbox (found on the file exchange) does allow periodic boundary conditions.
x = 2*pi*[0:.1:1];
y = cos(x);
SLM = slmengine(x,y,'knots',x,'endcond','periodic','regul',0,'result','pp','plot','on');
So a purely interpolating cubic spline, with periodic boundary conditions.
Related Question