clear %% np = 40; f = @(x) 0.95*sin(2*pi*x); t = linspace(0, 1, np); y = f(t); % values at nodes plot(t, y, '.-') hold on S = spinterp(t, y); t1 = linspace(0, 1, 3*np); sp = S(t1); plot(t1, sp) xlabel('x') ylabel('f(x)') title('Function and cubic spline interpolant') legend('function', 'spline interpolation') grid on