how to interpolate the non uniform resolution in cubic spline?
조회 수: 7 (최근 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!