Cubic Spline Program

前端 未结 2 1724
后悔当初
后悔当初 2020-12-29 15:12

I\'m trying to write a cubic spline interpolation program. I have written the program but, the graph is not coming out correctly. The spline uses natural boundary conditions

2条回答
  •  隐瞒了意图╮
    2020-12-29 15:47

    There was a bug in spline function, generated (n-2) by (n-2) should be symmetric:

    lower = h(2:end);
    main  = 2*(h(1:end-1) + h(2:end));
    upper = h(1:end-1);
    

    http://www.mpi-hd.mpg.de/astrophysik/HEA/internal/Numerical_Recipes/f3-3.pdf

提交回复
热议问题