Look-up Table "Newton Interpolation"

2 vues (au cours des 30 derniers jours)
Hala Shamsi
Hala Shamsi le 18 Nov 2020
Modifié(e) : John D'Errico le 18 Nov 2020
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 commentaire
John D'Errico
John D'Errico le 18 Nov 2020
Ok, so what is your question? Is it "Would someone please write the code for me?"

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 18 Nov 2020
Modifié(e) : John D'Errico le 18 Nov 2020
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.

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by