Hi,
Please find attached a demo program that implements a natural cubic spline for curve fitting. I converted the code form a c program published on the following web site.
Cubic Spline C Programs
I have only implemented the equidistant algorithm that assumes that the vector has a fixed "sample period"
I might get around to the variable distance algorithm at some time, but it's easy to download and convert to B4x if you need a more general version.
I am using it to interpolate ten minute weather data to five minutes to match some other 5 minute data I have. I could have used a linear interpolation, but I've always wanted to have a crack at splines as they are generally better than poly curve fits for the sort of data I am processing.
Enjoy
Best regards
Rob
Please find attached a demo program that implements a natural cubic spline for curve fitting. I converted the code form a c program published on the following web site.
Cubic Spline C Programs
I have only implemented the equidistant algorithm that assumes that the vector has a fixed "sample period"
I might get around to the variable distance algorithm at some time, but it's easy to download and convert to B4x if you need a more general version.
I am using it to interpolate ten minute weather data to five minutes to match some other 5 minute data I have. I could have used a linear interpolation, but I've always wanted to have a crack at splines as they are generally better than poly curve fits for the sort of data I am processing.
Enjoy
Best regards
Rob
Attachments
Last edited: