2-dimensional polynomial interpolation

16 Ansichten (letzte 30 Tage)
Mario Magana
Mario Magana am 25 Feb. 2019
Beantwortet: Mario Magana am 25 Feb. 2019
I am trying to obtain a polynomial in 2 variables (inditerminates) using a 2-dimensional mxn grid and the function interpolate in the Matlab environment and not an MuPAD. Can someone help me do this?

Antworten (2)

John D'Errico
John D'Errico am 25 Feb. 2019
Bearbeitet: John D'Errico am 25 Feb. 2019
No. You simply do NOT want to do this. It is a terribly bad idea.
Even 1-dimensional interpolation using any high degree polynomial is a terribly bad idea. But to try to do this in 2-d is just obscenely bad. But why?
First, you don't really say what order of a grid you are talking about. But you say mxn, for general m and n. Polynomial interpolation creates polynomials with nasty coefficients. Yes, I know. You learned about Taylor series in school. So if series are any good, then a polynomial interpolant must be great. But in fact, even series approximations tend to do insane things between the data points.
A simple example might be appropriate. Here is a surface I want to model using a 2-d polynomial.
Just a 7x7 array of points, so 49 points. But because this is an interpolation, there are 49 coefficients to generate. The second figure is the interpolation. You should notice the z axis is scaled with a factor if 10^13 on it.
The surface should go through the data points. But between them? Pure and utter CRAPOLA. 2d polynomial interpolation is an actively, really BAD idea. Have I said that loudly enough? Often enough?
Even for a smaller grid of points, say 5x5, there are 25 unknown coefficients to compute. Things go to hell fast. You just won't be able to do it.
Yes, I know your teacher taught you in school about things like Lagrange interpolation. Forget what they said. Even in 1-d, Lagrange interpolation is a bad idea. It works great to get the idea of interpolation across to students. But let it die a quiet death there. Do NOT try to move those ideas into 2-d. Do not even think about it.
One thing I seem to have to say over and over agian, is how bad an idea it is to try to write code to solve problems when existing, professionally written code is available. This is especially true if you have no clue what you are doing. And, yes, I'm sorry for saying that, but if you had to ask this question at all, then you have no real clue how to solve this problem. Do NOT try to solve it as you have asked.
So, instead, you have a trivial problem for tools like interp2 to solve. Is there any remotely VALID reason why you cannot use interp2, or one of the other alternatives? Even scatteredInterpolant would be a better choice, and you don't even have scattered data.

Mario Magana
Mario Magana am 25 Feb. 2019
Thank you for your prompt response.

Community Treasure Hunt

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

Start Hunting!

Translated by