how to interpolate the non uniform resolution in cubic spline?
2 views (last 30 days)
Show older comments
Hi all, if I have 6 segments with resolution of 8,8,8,8,8,12, why can not cubic spline interpolate correctly for the last segment? How to solve this problem? Thank you very much
2 Comments
John D'Errico
on 15 Dec 2017
Edited: John D'Errico
on 15 Dec 2017
Why can't you? Because you did not write the correct code. Sorry, but the computation is trivial with a cubic spline, written correctly to handle unequal spacing between the breaks. (Triviality is sometimes in the eye of the beholder.)
What did you do wrong? That is impossible to know, because we cannot magically see inside your computer, and you did not provide your code.
Most likely, you assumed that the data spacing was uniform, and wrote the equations and code to follow that assumption. So don't do it that way.
If this is for homework, then the issue is you need to write code using the correct equations. If this is for your work or whatever task you are trying to perform, then DON'T WRITE YOUR OWN SPLINE CODE. Use existing tools like spline, or pchip, or interp1, etc.
Accepted Answer
Image Analyst
on 15 Dec 2017
See my attached spline demo. Of course, you can put in any x value you want to get the estimated/spline value at that location.
More Answers (0)
See Also
Categories
Find more on Splines in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!