how to create a polynomial interpolation of two variables

4 次查看(过去 30 天)
how to create a polynomial interpolation of two variables with following data:
x=0:0.5:2;
y=0:0.1:0.4;
z=[13.2689 14.8741 16.4243 17.9337 19.4118]

回答(1 个)

John D'Errico
John D'Errico 2023-1-17
Sorry, but this is a common mistake made by people.
You really have only ONE variable there, since x and y are linearly related. Therefore you cannot perform a TWO dimensional interpolation.
x=0:0.5:2;
y=0:0.1:0.4;
plot(x,y,'o')
You CAN perform an interpolation of z as a function of x, or z as a function of y. They will be identical mathematically, due to the linear relationship between x and y.
  5 个评论
merwan behar
merwan behar 2023-1-18
I want to draw a two-dimensional graph, I can't do it with the surface function .
as the following figure
John D'Errico
John D'Errico 2023-1-18
You don't have two dimensions of information content in your data. Wanting to do something is nice. But wanting the mathemtically impossible is not enough.
As I showed, your data lives only perfectly along a straight line. And that makes it impossible.
You need to get data that provides information in TWO dimensions. Not just one. Again, here is your data in the (x,y) plane:
x=0:0.5:2;
y=0:0.1:0.4;
plot(x,y,'o-')
Do you see that the data lives along a straight line?
Instead, you want data that looks like this:
xgood = [0 1 2 0 1 2 0 1 2];
ygood = [0 0 0 .2 .2 .2 .4 .4 .4];
hold on
plot(xgood,ygood,'rs')
The data in red is data that explores the entire domain. And it allows you to draw the surface you want to see. The data you have is sadly, completely useless in this respect.
You need to understand the difference.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by