Look-up Table "Newton Interpolation"

I want to develop a function using cubic Newton polynomial to perform interpolation. For intermediate intervals, this is a nice choice because the unknown will be located in the interval in the middle of the four points necessary to generate the cubic. For the first and last intervals, I want to use a quadratic Newton polynomial. I also want the code detect when the user requests a value outside the range of x's. For such cases, the function should display an error message.
I know that, to develop such an algorithm, the table of x and f(x) values are first stored in a pair of one-dimensional arrays. These values are then passed to a function along with the x value you wish to evaluate. The function then performs two 1 tasks. First, it loops down through the table until it finds the interval within which the unknown lies. Then it applies a technique like Newton's interpolation to determine the proper f(x) value.

댓글 수: 1

John D'Errico
John D'Errico 2020년 11월 18일
Ok, so what is your question? Is it "Would someone please write the code for me?"

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2020년 11월 18일
편집: John D'Errico 2020년 11월 18일

0 개 추천

Let me suggest this is a bad idea. The result will be an interpolant that is not even differentiable across the data points. A nice choice? Actually an actively bad idea, when twice differentiable interpolating splines are so trivially available. Or you can use pchip, which, while only once differentiable, is also shape preserving. Or you can use interp1, which makes things trivially easy to use.
Writing your own code to do things like this is NEVER a good choice.
If you want us to write the code for you to do as requested, sorry, but that would only be because this is your homework. We don't do homework assignments for people.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2020년 11월 18일

편집:

2020년 11월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by