// spline linear figure(1) xbasc() x=[1 10 20 30 40]; y=[1 30 -10 20 40]; plot2d(x',y',[-3],"011"," ",[-10,-40,50,50]); yi=interpln([x;y],-4:45); plot2d((-4:45)',yi',[3],"000"); xtitle("spline lineare") // continuita' della spline e della spline veloce a = -8; b = 8; x = linspace(a,b,20)'; y = sinc(x); dk = splin(x,y); // not_a_knot df = splin(x,y, "fast"); xx = linspace(a,b,800)'; [yyk, yy1k, yy2k] = interp(xx, x, y, dk); [yyf, yy1f, yy2f] = interp(xx, x, y, df); figure(2) xbasc() subplot(3,1,1) plot2d(xx, [yyk yyf]) plot2d(x, y, style=-9) legends(["not_a_knot spline","fast sub-spline","punti di interpolazione"],... [1 2 -9], "ur",%f) xtitle("spline interpolation") subplot(3,1,2) plot2d(xx, [yy1k yy1f]) legends(["not_a_knot spline","fast sub-spline"], [1 2], "ur",%f) xtitle("derivata prima spline interpolante") subplot(3,1,3) plot2d(xx, [yy2k yy2f]) legends(["not_a_knot spline","fast sub-spline"], [1 2], "lr",%f) xtitle("derivata seconda spline interpolante") // estrapolazione x = linspace(0,1,11)'; y = cosh(x-0.5); d = splin(x,y); xx = linspace(-0.5,1.5,401)'; yy0 = interp(xx,x,y,d,"C0"); yy1 = interp(xx,x,y,d,"linear"); yy2 = interp(xx,x,y,d,"natural"); yy3 = interp(xx,x,y,d,"periodic"); figure(3) xbasc() plot2d(xx,[yy0 yy1 yy2 yy3],[2 3 4 5],frameflag=2) xtitle(" modi diversi per valutare la spline fuori dal suo dominio")