how to interpolate the non uniform resolution in cubic spline?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
John D'Errico
2017-12-15
编辑:John D'Errico
2017-12-15
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.
采纳的回答
Image Analyst
2017-12-15
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Splines 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!