% Octave/Matlab example to plot a cubic spline through specified % points % % modified from % https://octave.sourceforge.io/octave/function/spline.html % % M.V.Wickerhauser % 2019-10-11 % % x = 0:3; y = [1 1 5 6]; % knots xp = 0:0.1:3; % interpolated points yns = spline (x,y,xp); % natural spline ycs = spline (x,[0,y,0],xp); % clamped spline % plot the knots, the natural spline, and the clamped spline plot ( x,y,"r*", xp, yns,"g-", xp, ycs, "b-"); title ("Cubic spline fits to specified points", "fontsize",16); legend ("knots","natural spline","clamped spline", "location","southeast" );